@param string $number

@return Decimal

@throws \InvalidArgumentException If the number is invalid, or exceeds the size of an int on this platform.
348777
public static function parse(string $number) : Decimal
    {
        if (preg_match('/^(\-?)([0-9]+)(?:\.([0-9]+))?$/', $number, $matches) !== 1) {
            throw new \InvalidArgumentException('Invalid number: ' . $number);
        }

        $sign = $matches[1];
        $integral = $matches[2];

        if (isset($matches[3])) {
            $fractional = rtrim($matches[3], '0');
        } else {
            $fractional = '';
        }

        $scale = strlen($fractional);

        $value = $integral . $fractional;
        $value = ltrim($value, '0');

        if ($value === '') {
            $value = '0';
        }

        $value = $sign . $value;

        $intValue = (int) $value;

        if ($value !== (string) $intValue) {
            throw new \InvalidArgumentException('Decimal number out of range for this platform: ' . $value);
        }

        return new Decimal($intValue, $scale);
    }
255247
protected static function validatePositiveInteger($integer)
    {
        $integer = max(0, (int) $integer);
        if (!$integer) {
            throw new \InvalidArgumentException('Argument number is not valid');
        }

        return (string) $integer;
    }
957395
public static function convert($number)
    {
        $number = preg_replace('/\,/i', '', $number);

        $number = preg_replace('/([^0-9\.\-])/i', '', $number);

        if (! is_numeric($number)) {
            return '0.00';
        }

        $isCents = (bool) preg_match('/^0.\d+$/', $number);

        return ($isCents ? '0' : null).number_format($number * 100., 0, '.', '');
    }
1068493
public function truncate(DecimalNumber $number, $precision)
    {
        $precision = $this->sanitizePrecision($precision);

        if ($number->getPrecision() <= $precision) {
            return $number;
        }

        if (0 === $precision) {
            return new DecimalNumber($number->getSign() . $number->getIntegerPart());
        }

        return new DecimalNumber(
            $number->getSign()
            . $number->getIntegerPart()
            . '.'
            . substr($number->getFractionalPart(), 0, $precision)
        );
    }
451288
public function number($number)
    {
        if ($number < 0) {
            $number   = -$number;
            $negative = self::NEGATIVE;
        } else {
            $negative = '';
        }
        $parts    = explode(self::DECIMAL, (string) $number, 2);
        $integers = $parts[0];
        if (strlen($integers) >= $this->digitsFirstGroup() + $this->minimumGroupingDigits()) {
            $todo     = substr($integers, 0, -$this->digitsFirstGroup());
            $integers = self::GROUP . substr($integers, -$this->digitsFirstGroup());
            while (strlen($todo) >= $this->digitsGroup() + $this->minimumGroupingDigits()) {
                $integers = self::GROUP . substr($todo, -$this->digitsGroup()) . $integers;
                $todo     = substr($todo, 0, -$this->digitsGroup());
            }
            $integers = $todo . $integers;
        }
        if (count($parts) > 1) {
            $decimals = self::DECIMAL . $parts[1];
        } else {
            $decimals = '';
        }

        return $this->digits($negative . $integers . $decimals);
    }
752005
public function gte($number)
    {
        return (bool) (bccomp($this->number, static::validateInputNumber($number), $this->precision) >= 0);
    }
1218792
public static function format($number, $decimals = null, $decimalPoint = null,
                                  $thousandsSeparator = null)
    {
        if (is_null($decimals)) {
            $decimals = self::$decimals;
        }
        if (is_null($decimalPoint)) {
            $decimalPoint = self::$decimalPoint;
        }
        if (is_null($thousandsSeparator)) {
            $thousandsSeparator = self::$thousandsSeparator;
        }
        return number_format($number, $decimals, $decimalPoint, $thousandsSeparator);
    }
1248638
public function eq($number)
    {
        return (bool) (bccomp($this->number, static::validateInputNumber($number), $this->precision) === 0);
    }
349090
public function lessStrict($number)
    {
        if (!is_int($number) && !is_float($number)) {
            throw new InvalidIntOrFloatException('number', $number);
        }

        if (!is_int($this->value) && !is_float($this->value)) {
            throw new InvalidIntOrFloatException($this->name, $this->value);
        } elseif ($this->value >= $number) {
            throw new NumberNotLessStrictlyException($this->name, $this->value, $number);
        }

        return $this;
    }
798198
public function lte($number)
    {
        return (bool) (bccomp($this->number, static::validateInputNumber($number), $this->precision) <= 0);
    }
48326
function internalNumber( $number )
    {
        if ( preg_match( '/^(['.$this->PositiveSymbol.']|['.$this->NegativeSymbol.'])?([0-9]*|[0-9]{1,3}(['.$this->ThousandsSeparator.'][0-9]{3,3})*)(['.$this->DecimalSymbol.'][0-9]+)?$/', trim( $number ) ) )
        {
            $number = str_replace( ' ', '', $number );
            if ( $this->PositiveSymbol )
                $number = str_replace( $this->PositiveSymbol, '', $number );
            $number = str_replace( $this->NegativeSymbol, '-', $number );
            $number = str_replace( $this->ThousandsSeparator, '', $number );
            $number = str_replace( $this->DecimalSymbol, '.', $number );
        }
        return $number;
    }
1319061
public function formatStandardNumber($number, $decimals = null)
    {
        $lang = $this->request->getSession()->getLang();

        if ($decimals === null) {
            $decimals = $lang->getDecimals();
        }

        return number_format($number, $decimals, '.', '');
    }
856499
private static function parseIntegerPart($number)
    {
        if ('' === $number || '0' === $number) {
            return '0';
        }

        if ('-' === $number) {
            return '-0';
        }

        $nonZero = false;

        for ($position = 0, $characters = strlen($number); $position < $characters; ++$position) {
            $digit = $number[$position];

            if (!isset(static::$numbers[$digit]) && !(0 === $position && '-' === $digit)) {
                throw new \InvalidArgumentException(
                    sprintf('Invalid integer part %1$s. Invalid digit %2$s found', $number, $digit)
                );
            }

            if (false === $nonZero && '0' === $digit) {
                throw new \InvalidArgumentException(
                    'Leading zeros are not allowed'
                );
            }

            $nonZero = true;
        }

        return $number;
    }
1331632
protected function _isValidNumer($number)
    {
        $valid = false;
        if (($length = strlen($number))) {
            $modSum = 0;
            $mod = $length % 2;

            // Luhn algorithm
            for ($pos = 0; $pos < $length; $pos++) {
                // taking digit to check..
                $currDigit = ( int ) $number{$pos};

                // multiplying if needed..
                $addValue = (($pos % 2 == $mod) ? 2 : 1) * $currDigit;

                // adding prepared current digit
                $modSum += ($addValue > 9) ? $addValue - 9 : $addValue;
            }

            $valid = ($modSum % 10) == 0;
        }

        return $valid;
    }
257584
public function setNumber($number = null)
    {
        $this->number = null !== $number ? floatval($number) : null;

        return $this;
    }
1214291
public static function getDecimalPlaces($number) {
		$decimalPlaces = 0;
		while ($number > 1 && $number != 0) {
			$number /= 10;
			$decimalPlaces -= 1;
		}
		while ($number < 1 && $number != 0) {
			$number *= 10;
			$decimalPlaces += 1;
		}
		return $decimalPlaces;
	}
833855
public function number($number, $decimals = 0)
    {
        if (!$this->localizer) {
            return number_format($number, $decimals);
        }

        return $this->localizer->number($number, $decimals);
    }