GNU Multiple Precision
- Introduction
- Installing/Configuring
- Requirements
- Installation
- Runtime Configuration
- Predefined Constants
- Examples
- GMP Functions
- gmp_abs — Absolute value
- gmp_add — Add numbers
- gmp_and — Bitwise AND
- gmp_binomial — Calculates binomial coefficient
- gmp_clrbit — Clear bit
- gmp_cmp — Compare numbers
- gmp_com — Calculates one's complement
- gmp_div_q — Divide numbers
- gmp_div_qr — Divide numbers and get quotient and remainder
- gmp_div_r — Remainder of the division of numbers
- gmp_div — Alias of gmp_div_q
- gmp_divexact — Exact division of numbers
- gmp_export — Export to a binary string
- gmp_fact — Factorial
- gmp_gcd — Calculate GCD
- gmp_gcdext — Calculate GCD and multipliers
- gmp_hamdist — Hamming distance
- gmp_import — Import from a binary string
- gmp_init — Create GMP number
- gmp_intval — Convert GMP number to integer
- gmp_invert — Inverse by modulo
- gmp_jacobi — Jacobi symbol
- gmp_kronecker — Kronecker symbol
- gmp_lcm — Calculate LCM
- gmp_legendre — Legendre symbol
- gmp_mod — Modulo operation
- gmp_mul — Multiply numbers
- gmp_neg — Negate number
- gmp_nextprime — Find next prime number
- gmp_or — Bitwise OR
- gmp_perfect_power — Perfect power check
- gmp_perfect_square — Perfect square check
- gmp_popcount — Population count
- gmp_pow — Raise number into power
- gmp_powm — Raise number into power with modulo
- gmp_prob_prime — Check if number is "probably prime"
- gmp_random_bits — Random number
- gmp_random_range — Random number
- gmp_random_seed — Sets the RNG seed
- gmp_random — Random number
- gmp_root — Take the integer part of nth root
- gmp_rootrem — Take the integer part and remainder of nth root
- gmp_scan0 — Scan for 0
- gmp_scan1 — Scan for 1
- gmp_setbit — Set bit
- gmp_sign — Sign of number
- gmp_sqrt — Calculate square root
- gmp_sqrtrem — Square root with remainder
- gmp_strval — Convert GMP number to string
- gmp_sub — Subtract numbers
- gmp_testbit — Tests if a bit is set
- gmp_xor — Bitwise XOR
- GMP — The GMP class
- GMP::__serialize — Serializes the GMP object
- GMP::__unserialize — Deserializes the data parameter into a GMP object
Anonymous ¶
10 years ago
Be careful with GMP - it considers leading zeros in a number string as meaning the number is in octal, whereas 'bc' doesn't:
gmp_strval["000100", 10] => 64
bcmul["000100", "1"] => 100
In order to have these functions available, PHP must be compiled with GMP support by using the --with-gmp option.
arancaytar dot ilyaran at gmail dot com ¶
13 years ago
Note that this parameter requires a path, as in --with-gmp=DIR, if gmp is installed in a non-standard location, which is almost always the case when you are building your own PHP installation in your home directory.
Obvious, but it's an easy mistake.
Elydreams Trend ¶
11 months ago
On Debian platforms, make sure you install the gmp development library first:
sudo apt-get install libgmp-dev
Just like other extensions, you need the libs installed before php compile will gracefully complete all.
omagaldadze at yahoo dot com ¶
9 years ago
On ArchLinux php 5.4.14-1 I had to uncomment the line
extension=gmp.so
in /etc/php/php.ini file.
Probably, restart of web server [e.g. Apache] is required if working from web.
oharry0535 at gmail dot com ¶
3 years ago
Under Windows you will need to un-comment the line in your php.ini file
;extension=gmp
within the php.ini and restart Apache.
MiquelFire ¶
13 years ago
With PHP 5.3 on Windows, you need to use the VC9 build, otherwise you will not have the dll to enable GMP
Chris ¶
13 years ago
Under Windows you will need to uncomment the line
;extension=php_gmp.dll
within the php.ini and restart Apache.
mike dot mackintosh at angrystatic dot com ¶
9 years ago
On Debian platforms, make sure you install the gmp development library first:
sudo apt-get install libgmp-dev
Just like other extensions, you need the libs installed before php compile will gracefully complete.
admin at ee-dd dot com ¶
10 years ago
on ubuntu you can get it from Synaptic Package Manager
just search words "gmp",you'll find it.