PHP GMP Functions
EditRocket provides the following information on GMP functions in the PHP source code builder.
resource gmp_abs ( resource $a ) - Get the absolute value of a number.
resource gmp_add ( resource $a , resource $b ) - Add two numbers.
resource gmp_and ( resource $a , resource $b ) - Calculates logical AND of two GMP numbers.
void gmp_clrbit ( resource &$a , int $index ) - Clears (sets to 0) bit index in a. The index starts at 0.
int gmp_cmp ( resource $a , resource $b ) - Compares two numbers.
resource gmp_com ( resource $a ) - Returns the one's complement of a.
-
resource gmp_div_q ( resource $a , resource $b [, int $round ] ) - Divides a by b and returns the integer result.
array gmp_div_qr ( resource $n , resource $d [, int $round ] ) - The function divides n by d.
resource gmp_div_r ( resource $n , resource $d [, int $round ] ) - Calculates remainder of the integer division of n by d. The remainder has the sign of the n argument, if not zero.
resource gmp_divexact ( resource $n , resource $d ) - Divides n by d, using fast exact division algorithm. This function produces correct results only when it is known in advance that d divides n.
resource gmp_fact ( int $a ) - Calculates factorial (a!) of a.
resource gmp_gcd ( resource $a , resource $b ) - Calculate greatest common divisor of a and b. The result is always positive even if either of, or both, input operands are negative.
array gmp_gcdext ( resource $a , resource $b ) - Calculates g, s, and t, such that a*s + b*t = g = gcd(a,b), where gcd is the greatest common divisor. Returns an array with respective elements g, s and t.
int gmp_hamdist ( resource $a , resource $b ) - Returns the hamming distance between a and b. Both operands should be non-negative.
resource gmp_init ( mixed $number [, int $base ] ) - Creates a GMP number from an integer or string.
int gmp_intval ( resource $gmpnumber ) - This function allows to convert GMP number to integer.
resource gmp_invert ( resource $a , resource $b ) - Computes the inverse of a modulo b.
int gmp_jacobi ( resource $a , resource $p ) -
int gmp_legendre ( resource $a , resource $p ) -
resource gmp_mod ( resource $n , resource $d ) - Calculates n modulo d. The result is always non-negative, the sign of d is ignored.
resource gmp_mul ( resource $a , resource $b ) - Multiplies a by b and returns the result.
resource gmp_neg ( resource $a ) - Returns the negative value of a number.
resource gmp_nextprime ( int $a ) - Find next prime number
resource gmp_or ( resource $a , resource $b ) - Calculates logical inclusive OR of two GMP numbers.
bool gmp_perfect_square ( resource $a ) - Check if a number is a perfect square.
int gmp_popcount ( resource $a ) - Get the population count.
resource gmp_pow ( resource $base , int $exp ) - Raise base into power exp.
resource gmp_powm ( resource $base , resource $exp , resource $mod ) - Calculate (base raised into power exp) modulo mod. If exp is negative, result is undefined.
int gmp_prob_prime ( resource $a [, int $reps ] ) - The function uses Miller-Rabin's probabilistic test to check if a number is a prime.
resource gmp_random ( int $limiter ) - Generate a random number. The number will be between zero and the number of bits per limb multiplied by limiter. If limiter is negative, negative numbers are generated.
int gmp_scan0 ( resource $a , int $start ) - Scans a, starting with bit start, towards more significant bits, until the first clear bit is found.
int gmp_scan1 ( resource $a , int $start ) - Scans a, starting with bit start, towards more significant bits, until the first set bit is found.
void gmp_setbit ( resource &$a , int $index [, bool $set_clear ] ) - Sets bit index in a.
int gmp_sign ( resource $a ) - Checks the sign of a number.
resource gmp_sqrt ( resource $a ) - Calculates square root of a.
array gmp_sqrtrem ( resource $a ) - Calculate the square root of a number, with remainder.
string gmp_strval ( resource $gmpnumber [, int $base ] ) - Convert GMP number to string representation in base base. The default base is 10.
resource gmp_sub ( resource $a , resource $b ) - Subtracts b from a and returns the result.
bool gmp_testbit ( resource $a , int $index ) - Tests if the specified bit is set.
resource gmp_xor ( resource $a , resource $b ) - Calculates logical exclusive OR (XOR) of two GMP numbers.