gmp_init
is a function in PHP that creates a GMP number.
GMP stands for GNU Multiple Precision
gmp_init(int|string $num, int $base = 0): GMP
num
: This can either be of the string
type or the int
type.If
num
is of thestring
type, it can be a decimal, hexadecimal, or octal number.
base
: An optional parameter. The base
can have values from 2 to 36
. The value by default is zero.If the value of base
is zero, the leading characters determine the actual base.
If the first two characters are 0x/0X
, then hexadecimal is considered.
If the first two characters are 0b/0B
, the binary is considered.
If the first character is 0
then octal is considered.
If these conditions are not satisfied, the decimal is considered.
The function returns a GMP number.
<?php$val1 = gmp_init(12);echo $val1."\n";$val2 = gmp_init(0101, 2);echo $val2."\n";?>
12
5