Bevezet�s
These functions allow you to work with arbitrary-length integers
using the GNU MP library.
These functions have been added in PHP 4.0.4.
Megjegyz�s:
Most GMP functions accept GMP number arguments, defined as
resource below. However, most of these
functions will also accept numeric and string arguments, given
that it is possible to convert the latter to a number. Also,
if there is a faster function that can operate on integer arguments,
it would be used instead of the slower function when the supplied arguments are
integers. This is done transparently, so the bottom line is that
you can use integers in every function that expects GMP
number. See also the gmp_init() function.
Figyelem |
If you want to explicitly specify a large integer,
specify it as a string. If you don't do that, PHP will
interpret the integer-literal first, possibly resulting
in loss of precision, even before GMP
comes into play.
|
K�vetelm�nyek
You can download the GMP library from . This site also has the
GMP manual available.
You will need GMP version 2 or better to use these functions. Some
functions may require more recent version of the GMP library.
Telep�t�s
In order to have these functions available, you must compile PHP with
GMP support by using the --with-gmp option.
Fut�sidej� be�ll�t�sok
Ez a kiterjeszt�s semmilyen konfigur�ci�s
be�ll�t�sokat nem defini�l.
Er�forr�s t�pusok
Ez a kiterjeszt�s semmilyen er�forr�s
t�pust nem defini�l.
El�re defini�lt �lland�k
Az itt list�zott �lland�kat ez a kiterjeszt�s
defini�lja, �s csak akkor el�rhet�ek, ha az adott
kiterjeszt�s be van ford�tva a PHP-be, vagy
dinamikusan bet�lt�tt.
P�ld�k
P�lda 1. Factorial function using GMP <?php
function fact ($x) {
if ($x <= 1)
return 1;
else
return gmp_mul ($x, fact ($x-1));
}
print gmp_strval (fact (1000)) . "\n";
?> |
|
This will calculate factorial of 1000 (pretty big number)
very fast.