php-doc-en/reference/gmp/reference.xml

142 lines
3.8 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<!-- Purpose: mathcrypto.math -->
<!-- Membership: bundled, external -->
<reference xml:id="ref.gmp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>GMP Functions</title>
<titleabbrev>GMP</titleabbrev>
<partintro>
<section xml: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>
<note>
<simpara>
This extension is available on Windows platforms since PHP 5.1.0.
</simpara>
</note>
</section>
<section xml:id="gmp.requirements">
&reftitle.required;
<para>
You can download the <acronym>GMP</acronym> library from <link
xlink:href="&url.gmp;">&url.gmp;</link>. 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>
&reference.gmp.configure;
<section xml:id="gmp.configuration">
&reftitle.runtime;
&no.config;
</section>
<section xml:id="gmp.resources">
&reftitle.resources;
<para>
Most GPM functions operate on or return GMP number resources.
</para>
</section>
&reference.gmp.constants;
<section xml:id="gmp.examples">
&reftitle.examples;
<para>
<example>
<title>Factorial function using GMP</title>
<programlisting role="php">
<![CDATA[
<?php
function fact($x)
{
$return = 1;
for ($i=2; $i < $x; $i++) {
$return = gmp_mul($return, $i);
}
return $return;
}
echo gmp_strval(fact(1000)) . "\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
This will calculate factorial of 1000 (pretty big number)
very fast.
</para>
</section>
<section xml:id="gmp.seealso">
&reftitle.seealso;
<para>
More mathematical 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.entities.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
-->