★ wanayoo — archive 1999 http://fr.php.net/manual/ref.gmp.phpNouvelle recherche | Portail wanayoo
PHP Tuesday, March 20, 2001  
downloads | documentation | faq | support | reporting bugs | links 

search for in the  

lookup:
PHP ManualPHP Manual
Function ReferenceFunction Reference
 ApacheApache
 ArraysArrays
 AspellAspell
 BC mathBC math
 CalendarCalendar
 CCVSCCVS
 COMCOM
 Classes/ObjectsClasses/Objects
 ClibPDFClibPDF
 CURLCURL
 CybercashCybercash
 dbadba
 Date/timeDate/time
 dBasedBase
 DBMDBM
 DirectoriesDirectories
 DOM XMLDOM XML
 Errors and LoggingErrors and Logging
 fileProfilePro
 FilesystemFilesystem
 FDFFDF
 FTPFTP
 FunctionsFunctions
 gettextgettext
 GMPGMP
 HTTPHTTP
 HyperwaveHyperwave
 ICAPICAP
 GraphicsGraphics
 IMAPIMAP
 InformixInformix
 InterBaseInterBase
 Ingres IIIngres II
 LDAPLDAP
 MailMail
 Math.Math.
 MCALMCAL
 mcryptmcrypt
 mhashmhash
 MS SQL ServerMS SQL Server
 Misc.Misc.
 mSQLmSQL
 MySQLMySQL
 NetworkNetwork
 ODBCODBC
 OCI8OCI8
 OpenSSLOpenSSL
 OracleOracle
 OvrimosSQLOvrimosSQL
 Output ControlOutput Control
 PDFPDF
 Verisign Payflow ProVerisign Payflow Pro
 PHP options/infoPHP options/info
 POSIXPOSIX
 PostgreSQLPostgreSQL
 Program ExecutionProgram Execution
 PspellPspell
 ReadlineReadline
 RecodeRecode
 PCREPCRE
 RegexpsRegexps
 SatelliteSatellite
 SemaphoreSemaphore
 SESAMSESAM
 SessionsSessions
 shmopshmop
 SWFSWF
 SNMPSNMP
 SocketsSockets
 StringsStrings
 SybaseSybase
 URLsURLs
 VariablesVariables
 WDDXWDDX
 XMLXML
 XSLTXSLT
 YAZYAZ
 YP/NISYP/NIS
 ZlibZlib

previoustextdomain
gmp_initnext

Last updated: Mon, 08 Jan 2001

XXV. GMP functions

These functions allow you to work with arbitrary-length integers using the GNU MP library. In order to have these functions available, you must compile PHP with GMP support by using the --with-gmp option.

You can download the GMP library from http://www.swox.com/gmp/. 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.

These functions have been added in PHP 4.0.4.

Note: 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.

Example 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 factiorial of 1000 (pretty big number) very fast.

Table of Contents
gmp_init — Create GMP number
gmp_intval — Convert GMP number to integer
gmp_strval — Convert GMP number to string
gmp_add — Add numbers
gmp_sub — Subtract numbers
gmp_mul — Multiply numbers
gmp_div_q — Divide numbers
gmp_div_r — Remainder of the division of numbers
gmp_div_qr — Divide numbers and get quotient and remainder
gmp_div — Divide numbers
gmp_mod — Modulo operation
gmp_divexact — Exact division of numbers
gmp_cmp — Compare numbers
gmp_neg — Negate number
gmp_abs — Absolute value
gmp_sign — Sign of number
gmp_fact — Factorial
gmp_sqrt — Square root
gmp_sqrtrm — Square root with remainder
gmp_perfect_square — Perfect square check
gmp_pow — Raise number into power
gmp_powm — Raise number into power with modulo
gmp_prob_prime — Check if number is "probably prime"
gmp_gcd — Calculate GCD
gmp_gcdext — Calculate GCD and multipliers
gmp_invert — Inverse by modulo
gmp_legendre — Legendre symbol
gmp_jacobi — Jacobi symbol
gmp_random — Random number
gmp_and — Logical AND
gmp_or — Logical OR
gmp_xor — Logical XOR
gmp_setbit — Set bit
gmp_clrbit — Clear bit
gmp_scan0 — Scan for 0
gmp_scan1 — Scan for 1
gmp_popcount — Population count
gmp_hamdist — Hamming distance
previoustextdomain
gmp_initnext

Last updated: Mon, 08 Jan 2001
add note | about notes

show source | credits | mirror sites:  

Copyright © 1998-2001 The PHP Group
All rights reserved.
This mirror generously provided by: L'Université Michel de Montaigne Bordeaux III
Last updated: Tue Mar 20 11:31:24 2001 MET