math/bigint/Gmp.php
public static function fromString(string $number, $base = null)
    {
        // Temporarily split the sign from the operand for easier matching. We will reattach it later.
        $sign   = 0 === strpos($number, '-') ? '-' : '';
        $number = ltrim($number, '-+');

        if (null === $base) {
            if (preg_match('#^(?:([1-9])\.)?([0-9]+)[eE]\+?([0-9]+)$#', $number, $matches)) {
                if (!empty($matches[1])) {
                    if ($matches[3] < strlen($matches[2])) {
                        throw new \InvalidArgumentException('Failed to create BigInt - malformed scientific notation of the number.');
                    }
                } else {
                    $matches[1] = '';
                }
                $number = str_pad(($matches[1] . $matches[2]), ($matches[3] + 1), '0', STR_PAD_RIGHT);
            } else {
                $base = 0;
            }
        }

        return new static(gmp_init($sign.$number, $base));
    }
public static function fromString(string $number, $base = null)
    {
        // Temporarily split the sign from the operand for easier matching. We will reattach it later.
        $sign   = 0 === strpos($number, '-') ? '-' : '';
        $number = ltrim($number, '-+');

        if (null === $base) {
            if (preg_match('#^(?:([1-9])\.)?([0-9]+)[eE]\+?([0-9]+)$#', $number, $matches)) {
                if (!empty($matches[1])) {
                    if ($matches[3] < strlen($matches[2])) {
                        throw new \InvalidArgumentException('Failed to create BigInt - malformed scientific notation of the number.');
                    }
                } else {
                    $matches[1] = '';
                }
                $number = str_pad(($matches[1] . $matches[2]), ($matches[3] + 1), '0', STR_PAD_RIGHT);
            } else {
                $base = 0;
            }
        }

        return new static(gmp_init($sign.$number, $base));
    }
public static function fromString ( string $ number , $ base = null ) { // Temporarily split the sign from the operand for easier matching. We will reattach it later. $ sign = 0 === strpos ( $ number , '-' ) ? '-' : '' ; $ number = ltrim ( $ number , '-+' ) ; if ( null === $ base ) { if ( preg_match ( '#^(?:([1-9])\.)?([0-9]+)[eE]\+?([0-9]+)$#' , $ number , $ matches ) ) { if ( ! empty ( $ matches [ 1 ] ) ) { if ( $ matches [ 3 ] < strlen ( $ matches [ 2 ] ) ) { throw new \ InvalidArgumentException ( 'Failed to create BigInt - malformed scientific notation of the number.' ) ; } } else { $ matches [ 1 ] = '' ; } $ number = str_pad ( ( $ matches [ 1 ] . $ matches [ 2 ] ) , ( $ matches [ 3 ] + 1 ) , '0' , STR_PAD_RIGHT ) ; } else { $ base = 0 ; } } return new static ( gmp_init ( $ sign . $ number , $ base ) ) ; }
Converts the arbitrary string represented number into a BigInt instance representing the number
in decimal format.

The number can be in scientific notation on top of other formats supported natively by GMP (decimal,
hexadecimal or octal).

@param   string      $number
@param   int|null    $base
Converts the arbitrary string represented number into a BigInt instance representing the number in decimal format .