Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 3081

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>GMP functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Function Reference"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="textdomain"
HREF="function.textdomain.html"><LINK
REL="NEXT"
TITLE="gmp_abs"
HREF="function.gmp-abs.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.textdomain.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.gmp-abs.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.gmp"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>XXXVI. GMP functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN29633"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.intro"
></A
>Introduction</H1
><P
>&#13;     These functions allow you to work with arbitrary-length integers
     using the GNU <SPAN
CLASS="acronym"
>MP</SPAN
> library.
    </P
><P
>&#13;     These functions have been added in PHP 4.0.4. 
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      Most GMP functions accept GMP number arguments, defined as
      <TT
CLASS="literal"
>resource</TT
> 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 <A
HREF="function.gmp-init.html"
><B
CLASS="function"
>gmp_init()</B
></A
> function.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>Warning</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>&#13;      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 <TT
CLASS="literal"
>GMP</TT
> 
      comes into play.
     </P
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>This extension is not
available on Windows platforms.</P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.requirements"
></A
>Requirements</H1
><P
>&#13;     You can download the <SPAN
CLASS="acronym"
>GMP</SPAN
> library from <A
HREF="http://www.swox.com/gmp/"
TARGET="_top"
>http://www.swox.com/gmp/</A
>. This site also has the
     <SPAN
CLASS="acronym"
>GMP</SPAN
> manual available.
    </P
><P
>&#13;     You will need GMP version 2 or better to use these functions. Some
     functions may require more recent version of the GMP library.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.installation"
></A
>Installation</H1
><P
>&#13;  In order to have these functions available, you must compile PHP with
  <SPAN
CLASS="acronym"
>GMP</SPAN
> support by using the <TT
CLASS="option"
>--with-gmp</TT
> option.
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.configuration"
></A
>Runtime Configuration</H1
><P
>This extension has no configuration directives defined in <TT
CLASS="filename"
>php.ini</TT
>.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.resources"
></A
>Resource Types</H1
><P
>This extension has no resource types defined.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.constants"
></A
>Predefined Constants</H1
><P
>&#13;The constants below are defined by this extension, and
will only be available when the extension has either
been compiled into PHP or dynamically loaded at runtime.
</P
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>GMP_ROUND_ZERO</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GMP_ROUND_PLUSINF</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>GMP_ROUND_MINUSINF</B
></TT
> 
    (<A
HREF="language.types.integer.html"
>integer</A
>)</DT
><DD
><P
>&#13;     
    </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.examples"
></A
>Examples</H1
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN29692"
></A
><P
><B
>Example 1. Factorial function using GMP</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
function fact ($x) {
    if ($x &#60;= 1) 
        return 1;
    else
        return gmp_mul ($x, fact ($x-1));
}

print gmp_strval (fact (1000)) . "\n";
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     This will calculate factorial of 1000 (pretty big number)
     very fast.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="gmp.seealso"
></A
>See Also</H1
><P
>&#13;     More mathmatical functions can be found in the sections
     <A
HREF="ref.bc.html"
>BCMath Arbitrary Precision Mathematics Functions</A
>
     and <A
HREF="ref.math.html"
>Mathematical Functions</A
>.
    </P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="function.gmp-abs.html"
>gmp_abs</A
>&nbsp;--&nbsp;Absolute value</DT
><DT
><A
HREF="function.gmp-add.html"
>gmp_add</A
>&nbsp;--&nbsp;Add numbers</DT
><DT
><A
HREF="function.gmp-and.html"
>gmp_and</A
>&nbsp;--&nbsp;Logical AND</DT
><DT
><A
HREF="function.gmp-clrbit.html"
>gmp_clrbit</A
>&nbsp;--&nbsp;Clear bit</DT
><DT
><A
HREF="function.gmp-cmp.html"
>gmp_cmp</A
>&nbsp;--&nbsp;Compare numbers</DT
><DT
><A
HREF="function.gmp-com.html"
>gmp_com</A
>&nbsp;--&nbsp;Calculates one's complement of a</DT
><DT
><A
HREF="function.gmp-div-q.html"
>gmp_div_q</A
>&nbsp;--&nbsp;Divide numbers</DT
><DT
><A
HREF="function.gmp-div-qr.html"
>gmp_div_qr</A
>&nbsp;--&nbsp;Divide numbers and get quotient and remainder</DT
><DT
><A
HREF="function.gmp-div-r.html"
>gmp_div_r</A
>&nbsp;--&nbsp;Remainder of the division of numbers</DT
><DT
><A
HREF="function.gmp-div.html"
>gmp_div</A
>&nbsp;--&nbsp;Divide numbers</DT
><DT
><A
HREF="function.gmp-divexact.html"
>gmp_divexact</A
>&nbsp;--&nbsp;Exact division of numbers</DT
><DT
><A
HREF="function.gmp-fact.html"
>gmp_fact</A
>&nbsp;--&nbsp;Factorial</DT
><DT
><A
HREF="function.gmp-gcd.html"
>gmp_gcd</A
>&nbsp;--&nbsp;Calculate GCD</DT
><DT
><A
HREF="function.gmp-gcdext.html"
>gmp_gcdext</A
>&nbsp;--&nbsp;Calculate GCD and multipliers</DT
><DT
><A
HREF="function.gmp-hamdist.html"
>gmp_hamdist</A
>&nbsp;--&nbsp;Hamming distance</DT
><DT
><A
HREF="function.gmp-init.html"
>gmp_init</A
>&nbsp;--&nbsp;Create GMP number</DT
><DT
><A
HREF="function.gmp-intval.html"
>gmp_intval</A
>&nbsp;--&nbsp;Convert GMP number to integer</DT
><DT
><A
HREF="function.gmp-invert.html"
>gmp_invert</A
>&nbsp;--&nbsp;Inverse by modulo</DT
><DT
><A
HREF="function.gmp-jacobi.html"
>gmp_jacobi</A
>&nbsp;--&nbsp;Jacobi symbol</DT
><DT
><A
HREF="function.gmp-legendre.html"
>gmp_legendre</A
>&nbsp;--&nbsp;Legendre symbol</DT
><DT
><A
HREF="function.gmp-mod.html"
>gmp_mod</A
>&nbsp;--&nbsp;Modulo operation</DT
><DT
><A
HREF="function.gmp-mul.html"
>gmp_mul</A
>&nbsp;--&nbsp;Multiply numbers</DT
><DT
><A
HREF="function.gmp-neg.html"
>gmp_neg</A
>&nbsp;--&nbsp;Negate number</DT
><DT
><A
HREF="function.gmp-or.html"
>gmp_or</A
>&nbsp;--&nbsp;Logical OR</DT
><DT
><A
HREF="function.gmp-perfect-square.html"
>gmp_perfect_square</A
>&nbsp;--&nbsp;Perfect square check</DT
><DT
><A
HREF="function.gmp-popcount.html"
>gmp_popcount</A
>&nbsp;--&nbsp;Population count</DT
><DT
><A
HREF="function.gmp-pow.html"
>gmp_pow</A
>&nbsp;--&nbsp;Raise number into power</DT
><DT
><A
HREF="function.gmp-powm.html"
>gmp_powm</A
>&nbsp;--&nbsp;Raise number into power with modulo</DT
><DT
><A
HREF="function.gmp-prob-prime.html"
>gmp_prob_prime</A
>&nbsp;--&nbsp;Check if number is "probably prime"</DT
><DT
><A
HREF="function.gmp-random.html"
>gmp_random</A
>&nbsp;--&nbsp;Random number</DT
><DT
><A
HREF="function.gmp-scan0.html"
>gmp_scan0</A
>&nbsp;--&nbsp;Scan for 0</DT
><DT
><A
HREF="function.gmp-scan1.html"
>gmp_scan1</A
>&nbsp;--&nbsp;Scan for 1</DT
><DT
><A
HREF="function.gmp-setbit.html"
>gmp_setbit</A
>&nbsp;--&nbsp;Set bit</DT
><DT
><A
HREF="function.gmp-sign.html"
>gmp_sign</A
>&nbsp;--&nbsp;Sign of number</DT
><DT
><A
HREF="function.gmp-sqrt.html"
>gmp_sqrt</A
>&nbsp;--&nbsp;Square root</DT
><DT
><A
HREF="function.gmp-sqrtrm.html"
>gmp_sqrtrm</A
>&nbsp;--&nbsp;Square root with remainder</DT
><DT
><A
HREF="function.gmp-strval.html"
>gmp_strval</A
>&nbsp;--&nbsp;Convert GMP number to string</DT
><DT
><A
HREF="function.gmp-sub.html"
>gmp_sub</A
>&nbsp;--&nbsp;Subtract numbers</DT
><DT
><A
HREF="function.gmp-xor.html"
>gmp_xor</A
>&nbsp;--&nbsp;Logical XOR</DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.textdomain.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.gmp-abs.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>textdomain</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>gmp_abs</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>