mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 02:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@81330 c90b9560-bf6c-de11-be94-00142212c4b1
136 lines
3.6 KiB
XML
136 lines
3.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.3 $ -->
|
|
<reference id="ref.gmp">
|
|
<title>GMP functions</title>
|
|
<titleabbrev>GMP</titleabbrev>
|
|
<partintro>
|
|
|
|
<section id="gmp.intro">
|
|
&reftitle.intro;
|
|
<simpara>
|
|
These functions allow you to work with arbitrary-length integers
|
|
using the GNU <acronym>MP</acronym> library.
|
|
</simpara>
|
|
<simpara>
|
|
These functions have been added in PHP 4.0.4.
|
|
</simpara>
|
|
<note>
|
|
<para>
|
|
Most GMP functions accept GMP number arguments, defined as
|
|
<literal>resource</literal> 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 <function>gmp_init</function> function.
|
|
</para>
|
|
</note>
|
|
<warning>
|
|
<simpara>
|
|
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 <literal>GMP</literal>
|
|
comes into play.
|
|
</simpara>
|
|
</warning>
|
|
</section>
|
|
|
|
<section id="gmp.requirenments">
|
|
&reftitle.required;
|
|
<para>
|
|
You can download the <acronym>GMP</acronym> library from <ulink
|
|
url="&url.gmp;">&url.gmp;</ulink>. This site also has the
|
|
<acronym>GMP</acronym> manual available.
|
|
</para>
|
|
<simpara>
|
|
You will need GMP version 2 or better to use these functions. Some
|
|
functions may require more recent version of the GMP library.
|
|
</simpara>
|
|
</section>
|
|
|
|
<section id="gmp.installation">
|
|
&reftitle.install;
|
|
<para>
|
|
In order to have these functions available, you must compile PHP with
|
|
<acronym>GMP</acronym> support by using the <option
|
|
role="configure">--with-gmp</option> option.
|
|
</para>
|
|
</section>
|
|
|
|
<section id="gmp.configuration">
|
|
&reftitle.runtime;
|
|
&no.config;
|
|
</section>
|
|
|
|
<section id="gmp.resources">
|
|
&reftitle.resources;
|
|
&no.resource;
|
|
</section>
|
|
|
|
&reference.gmp.constants;
|
|
|
|
<section id="gmp.examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Factorial function using GMP</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function fact ($x) {
|
|
if ($x <= 1)
|
|
return 1;
|
|
else
|
|
return gmp_mul ($x, fact ($x-1));
|
|
}
|
|
|
|
print gmp_strval (fact (1000)) . "\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
This will calculate factorial of 1000 (pretty big number)
|
|
very fast.
|
|
</para>
|
|
</section>
|
|
|
|
<section id="gmp.seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
More mathmatical functions can be found in the sections
|
|
<link linkend="ref.bc">BCMath Arbitrary Precision Mathematics Functions</link>
|
|
and <link linkend="ref.math">Mathematical Functions</link>.
|
|
</para>
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
&reference.gmp.functions;
|
|
|
|
</reference>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|
|
|