Round away from zero (or round towards infinity).

@param string $amount the amount to round

@return string
168753
private static function roundAwayFromZero($amount)
    {
        $result = self::roundTowardsZero($amount);

        if (0 != bccomp($amount, $result, self::BCSCALE)) {
            if (1 == bccomp($amount, '0', self::BCSCALE)) {
                $result = bcadd($result, '1', self::BCSCALE);
            } elseif (-1 == bccomp($amount, '0', self::BCSCALE)) {
                $result = bcsub($result, '1', self::BCSCALE);
            }
        }

        return $result;
    }
74458
public static function noCurrency($amount = null)
    {
        if (null === $amount) {
            $amount = '0';
        }

        return self::valueOf(strval($amount), Currency::valueOf(Currency::NONE));
    }
718085
public function getInWordsFloat($amount)
    {
        $words = array();

        $intPart = (int)$amount;
        $pointVariants = array('целая', 'целых', 'целых');
        $words[] = $this->sumString($intPart, RUtils::FEMALE, $pointVariants);

        $remainder = $this->_getFloatRemainder($amount);
        $signs = strlen($remainder) - 1;
        $words[] = $this->sumString($remainder, RUtils::FEMALE, self::$_FRACTIONS[$signs]);

        $result = trim(implode(' ', $words));
        return $result;
    }
84908
public function asFloat(Money $money)
    {
        $amount = $money->getAmount();
        $amount = (float) $amount;
        $amount = $amount / pow(10, $this->decimals);

        return $amount;
    }
1271351
public static function adsToClicks($amount): int
    {
        $amountAsString = (string)$amount;
        if (strpos($amountAsString, '.') !== false) {
            $ar = explode('.', $amountAsString);
            $ar[1] = str_pad($ar[1], 11, '0');
            $amountAsString = implode($ar);
        } else {
            $amountAsString = $amountAsString . '00000000000';
        }
        return (int)$amountAsString;
    }
1001956
function formatRawAmount($amount, $curr) {
    $dblAmount = $amount + 0.0;

    // Build Currency format table
    $curFormat = Array();
    $curFormat["036"]=2;
    $curFormat["124"]=2;
    $curFormat["203"]=2;
    $curFormat["208"]=2;
    $curFormat["348"]=2;
    $curFormat["392"]=0;
    $curFormat["554"]=2;
    $curFormat["578"]=2;
    $curFormat["702"]=2;
    $curFormat["752"]=2;
    $curFormat["756"]=2;
    $curFormat["826"]=2;
    $curFormat["840"]=2;
    $curFormat["978"]=2;
    $curFormat["985"]=2;

    $digCurr = $this->getISOCurrency("" . $curr);
    $exponent = $curFormat[$digCurr];
    $strAmount = "" . Round($dblAmount, $exponent);
    $strRetVal = "" . $strAmount;

    // decimal position
    $curpos = strpos($strRetVal, ".");

    // Pad with zeros
    if($curpos == true) {
      $padCount = $exponent - (strlen($strRetVal) - $curpos - 1);
      for($i=0;$i<$padCount;$i++) {
        $strRetVal .= "0";
      }
    } else {
      $padCount = $exponent;
      for($i=0;$i<$padCount;$i++) {
        $strRetVal .= "0";
      }
    }

    if($curpos !== false) {
      $strRetVal = substr($strRetVal, 0, $curpos) . substr($strRetVal, $curpos+1);
    }
    return $strRetVal;
  }
650271
public function round(int $scale = 0): Decimal
    {
        if ($scale >= $this->scale) {
            return $this;
        }

        return self::fromString(self::innerRound($this->value, $scale));
    }
935621
public function limit(int $amount)
    {
        $this->items = array_slice($this->items, 0, $amount);

        return $this;
    }
599356
private static function roundHalfUp($amount)
    {
        $result = self::roundToNearestIntegerIgnoringTies($amount);

        if (null == $result) {
            $result = self::roundToNearestIntegerIgnoringTies(bcadd($amount, '0.1', self::BCSCALE));
        }

        return $result;
    }
896574
final public static function bcround($number, $precision, $roundingMode = self::ROUND_HALF_UP)
    {
        if ($number instanceof Decimal) {
            $number = (string) $number;
        }

        $precision = self::normalizePrecision($precision);
        if (self::isNotDecimalString($number)) {
            return Decimal::create($number, $precision);
        }

        if ($roundingMode === self::ROUND_HALF_UP) {
            return Decimal::create(self::bcRoundHalfUp($number, $precision), $precision);
        }

        $firstDecimalAfterPrecision = self::getFirstDecimalAfterPrecision($number, $precision);
        if ($firstDecimalAfterPrecision === self::HALF) {
            $result = self::roundTied($number, $precision, $roundingMode);
        } else {
            $result = self::roundNotTied($firstDecimalAfterPrecision, $number, $precision);
        }

        /*
         * Arbitrary precision arithmetic allows for '-0.0' which is not equal to '0.0' if compared with bccomp.
         * We have no use for this behaviour, so negative numbers have to be checked if they are minus zero,
         * so we can convert them into unsigned zero and return that.
         */
        $result = self::normalizeZero($result, $precision);

        return Decimal::create($result, $precision);
    }
64262
public function reverse($amount = null)
    {
        $builder = new HpsGiftCardServiceReverseBuilder($this);
        return $builder
            ->withAmount($amount)
            ->withCurrency('usd');
    }
530415
public function round($number, $precision = 0, $mode = PHP_ROUND_HALF_UP)
    {
        return $this->runExpressionFunction3Param('round', $number, $precision, $mode);
    }
940492
protected function parseAmountDecimalSeparator($amount) {
    $decimal_separator_counts = [];
    foreach ($this->decimalSeparators as $decimal_separator) {
      $decimal_separator_counts[$decimal_separator] = \mb_substr_count($amount, $decimal_separator);
    }
    $decimal_separator_counts_filtered = array_filter($decimal_separator_counts);
    if (count($decimal_separator_counts_filtered) > 1 || reset($decimal_separator_counts_filtered) !== FALSE && reset($decimal_separator_counts_filtered) != 1) {
      return FALSE;
    }
    return str_replace($this->decimalSeparators, '.', $amount);
  }
1250230
public function round($decimals = 2) {

		if(false === ('-' . intval($decimals) == '-' . $decimals)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($decimals)), E_USER_ERROR);
		}

		return $this -> convert(function($number, $decimals) {
			return round($number, $decimals);
		}, [$decimals]);
	}
203573
public function desaturate($amount)
    {
        if ($amount < 0 || $amount > 100) {
            throw new InvalidArgumentException('The given amount must be between 0 and 100');
        }
        $amount /= 100;
        $this->saturation -= $this->saturation * $amount;

        return $this;
    }
1203074
public function dec($field, $amount = 1) {
        $this->checkIncOrDecAmount($amount);

        $data = [$field => ['exp', "{$field} - {$amount}"]];
        return $this->update($data);
    }
292891
public static function readFloatval($amount, array $options = []) {
		$amount = self::numberToFromNativeLanguage($amount . '', $options, true);
		$negative = strpos($amount, '-') !== false || strpos($amount, '(') !== false;
		$amount = str_replace(self::$options['locale_options']['mon_thousands_sep'], '', $amount);
		// handle decimal separator
		if (self::$options['locale_options']['mon_decimal_point'] !== '.') {
			$amount = str_replace(self::$options['locale_options']['mon_decimal_point'], '.', $amount);
		}
		$amount = preg_replace('/[^0-9.]/', '', $amount);
		if ($negative) {
			$amount = '-' . $amount;
		}
		// sanitize only check
		if (!empty($options['valid_check'])) {
			return (filter_var($amount, $options['valid_check_type'] ?? FILTER_VALIDATE_FLOAT) !== false);
		}
		// if we are processing bc numeric data type
		if (!empty($options['bcnumeric'])) {
			$temp = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
			if ($temp === false || $temp === '') {
				$temp = '0';
			}
			return $temp;
		}
		// process based on type
		if (($options['valid_check_type'] ?? '') === FILTER_VALIDATE_INT) {
			return intval($amount);
		} else {
			return floatval($amount);
		}
	}