mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fixed the indentation.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@37324 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
119c75f8c3
commit
0bf790cb50
1 changed files with 283 additions and 266 deletions
|
@ -1,58 +1,61 @@
|
|||
<reference id="ref.gmp">
|
||||
<title>GMP functions</title>
|
||||
<titleabbrev>GMP</titleabbrev>
|
||||
<partintro>
|
||||
<partintro>
|
||||
<simpara>
|
||||
These functions allow you to work with arbitrary-length integers
|
||||
using GNU <acronym>MP</acronym> library. 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.
|
||||
These functions allow you to work with arbitrary-length integers
|
||||
using GNU <acronym>MP</acronym> library. 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.
|
||||
</simpara>
|
||||
<simpara>
|
||||
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.
|
||||
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.
|
||||
</simpara>
|
||||
<simpara>
|
||||
You will need GMP version 2 or better to use these functions. Some
|
||||
functions may require more recent version of the GMP library.
|
||||
You will need GMP version 2 or better to use these functions. Some
|
||||
functions may require more recent version of the GMP library.
|
||||
</simpara>
|
||||
<simpara>
|
||||
These functions have been added in PHP 4.0.4.
|
||||
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 accept also numeric and string arguments, given it's possible
|
||||
to convert the latter to number. Also, if there's faster function that
|
||||
can operate on integer arguments, it would be used instead of
|
||||
slower function when supplied arguments are integers. This is done
|
||||
transparently, so the bootom line is that you can use integers in
|
||||
every function that expects GMP number. See also
|
||||
<function>gmp_init</function> function.
|
||||
</para></note>
|
||||
<note>
|
||||
<para>
|
||||
Most GMP functions accept GMP number arguments, defined as
|
||||
<literal>resource</literal> below. However, most of these
|
||||
functions will accept also numeric and string arguments, given
|
||||
it's possible to convert the latter to number. Also, if there's
|
||||
faster function that can operate on integer arguments, it would
|
||||
be used instead of slower function when supplied arguments are
|
||||
integers. This is done transparently, so the bootom line is that
|
||||
you can use integers in every function that expects GMP
|
||||
number. See also <function>gmp_init</function> function.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title>Factorial function using GMP</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Factorial function using GMP</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
function fact($x) {
|
||||
if($x <= 1)
|
||||
function fact ($x) {
|
||||
if ($x <= 1)
|
||||
return 1;
|
||||
else
|
||||
return gmp_mul($x,fact($x-1));
|
||||
else
|
||||
return gmp_mul ($x, fact ($x-1));
|
||||
}
|
||||
|
||||
print gmp_strval(fact(1000))."\n";
|
||||
print gmp_strval (fact (1000)) . "\n";
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
This will calculate factiorial of 1000 (pretty big number)
|
||||
very fast.
|
||||
</para>
|
||||
</partintro>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
This will calculate factiorial of 1000 (pretty big number)
|
||||
very fast.
|
||||
</para>
|
||||
</partintro>
|
||||
|
||||
<refentry id="function.gmp-init">
|
||||
<refnamediv>
|
||||
|
@ -64,34 +67,35 @@ print gmp_strval(fact(1000))."\n";
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_init</function></funcdef>
|
||||
<paramdef>mixed <parameter>number</parameter></paramdef>
|
||||
<paramdef>mixed <parameter>number</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Creates a GMP number from integer or string. String representation
|
||||
can be decimal or hexadecimal. In the latter case, the string should
|
||||
start with <literal>0x</literal>.
|
||||
Creates a GMP number from integer or string. String
|
||||
representation can be decimal or hexadecimal. In the latter case,
|
||||
the string should start with <literal>0x</literal>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating GMP number</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Creating GMP number</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$a = gmp_init(123456);
|
||||
$b = gmp_init("0xFFFFDEBACDFEDF7200");
|
||||
$a = gmp_init (123456);
|
||||
$b = gmp_init ("0xFFFFDEBACDFEDF7200");
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
It is not necessary to call this function if you want to use
|
||||
integer or string in place of GMP number in GMP functions, like
|
||||
<function>gmp_add</function>. Function arguments are automatically
|
||||
converted to GMP numbers, if such conversion is possible and needed,
|
||||
using the same rules as <function>gmp_init</function>.
|
||||
</para>
|
||||
</note>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
It is not necessary to call this function if you want to use
|
||||
integer or string in place of GMP number in GMP functions, like
|
||||
<function>gmp_add</function>. Function arguments are
|
||||
automatically converted to GMP numbers, if such conversion is
|
||||
possible and needed, using the same rules as
|
||||
<function>gmp_init</function>.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -109,13 +113,14 @@ print gmp_strval(fact(1000))."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
This function allows to convert GMP number to integer.
|
||||
<warning><simpara>
|
||||
This function returns useful result only if the number actually
|
||||
fits the PHP integer (i.e., signed long type). If you want just to
|
||||
print the GMP number, use <function>gmp_strval</function>.
|
||||
</simpara>
|
||||
</warning>
|
||||
This function allows to convert GMP number to integer.
|
||||
<warning>
|
||||
<simpara>
|
||||
This function returns useful result only if the number actually
|
||||
fits the PHP integer (i.e., signed long type). If you want just
|
||||
to print the GMP number, use <function>gmp_strval</function>.
|
||||
</simpara>
|
||||
</warning>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -137,21 +142,21 @@ print gmp_strval(fact(1000))."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Convert GMP number to string representation in base
|
||||
<parameter>base</parameter>. The default base is 10.
|
||||
Allowed values for the base are from 2 to 36.
|
||||
Convert GMP number to string representation in base
|
||||
<parameter>base</parameter>. The default base is 10. Allowed
|
||||
values for the base are from 2 to 36.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Converting GMP number to string</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Converting GMP number to string</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$a = gmp_init("0x41682179fbf5");
|
||||
printf("Decimal: %s, 36-based: %s", gmp_strval($a), gmp_strval($a,36));
|
||||
$a = gmp_init("0x41682179fbf5");
|
||||
printf ("Decimal: %s, 36-based: %s", gmp_strval($a), gmp_strval($a,36));
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -170,8 +175,8 @@ print gmp_strval(fact(1000))."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Add two GMP numbers. The result will be GMP number representing
|
||||
the sum of the arguments.
|
||||
Add two GMP numbers. The result will be GMP number representing
|
||||
the sum of the arguments.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -191,9 +196,9 @@ print gmp_strval(fact(1000))."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Subtract <parameter>b</parameter> from <parameter>a</parameter>
|
||||
and returns the result.
|
||||
</para>
|
||||
Subtract <parameter>b</parameter> from <parameter>a</parameter>
|
||||
and returns the result.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -212,8 +217,8 @@ print gmp_strval(fact(1000))."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Multiplies <parameter>a</parameter> by <parameter>b</parameter>
|
||||
and returns the result.
|
||||
Multiplies <parameter>a</parameter> by <parameter>b</parameter>
|
||||
and returns the result.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -236,37 +241,38 @@ print gmp_strval(fact(1000))."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Divides <parameter>a</parameter> by <parameter>b</parameter>
|
||||
and returns the integer result. The result rounding is defined by
|
||||
the <parameter>round</parameter>, which can have the following
|
||||
values:
|
||||
<itemizedlist>
|
||||
Divides <parameter>a</parameter> by <parameter>b</parameter> and
|
||||
returns the integer result. The result rounding is defined by the
|
||||
<parameter>round</parameter>, which can have the following
|
||||
values:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<parameter>GMP_ROUND_ZERO</parameter>: The result is truncated
|
||||
towards 0.
|
||||
<parameter>GMP_ROUND_ZERO</parameter>: The result is truncated
|
||||
towards 0.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<parameter>GMP_ROUND_PLUSINF</parameter>: The result is
|
||||
rounded towards <literal>+infinity</literal>.
|
||||
rounded towards <literal>+infinity</literal>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<parameter>GMP_ROUND_MINUSINF</parameter>: The result is
|
||||
rounded towards <literal>-infinity</literal>.
|
||||
rounded towards <literal>-infinity</literal>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<simpara>
|
||||
This function can also be called as <function>gmp_div</function>.
|
||||
</simpara>
|
||||
<para>
|
||||
See also <function>gmp_div_r</function>,
|
||||
<function>gmp_div_qr</function>
|
||||
</para>
|
||||
<simpara>
|
||||
This function can also be called as <function>gmp_div</function>.
|
||||
</simpara>
|
||||
<para>
|
||||
See also <function>gmp_div_r</function>, <function>gmp_div_qr</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -288,17 +294,19 @@ rounded towards <literal>-infinity</literal>.
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates remainder of the integer division of
|
||||
<parameter>n</parameter> by <parameter>d</parameter>. The remainder
|
||||
has the sign of the <parameter>n</parameter> argument, if not zero.
|
||||
Calculates remainder of the integer division of
|
||||
<parameter>n</parameter> by <parameter>d</parameter>. The
|
||||
remainder has the sign of the <parameter>n</parameter> argument,
|
||||
if not zero.
|
||||
</para>
|
||||
<para>
|
||||
See the <function>gmp_div_q</function> function for description
|
||||
of the <parameter>round</parameter> argument.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>gmp_div_q</function>,
|
||||
<function>gmp_div_qr</function>
|
||||
</para>
|
||||
<para>
|
||||
See the <function>gmp_div_q</function> function for description
|
||||
of the <parameter>round</parameter> argument.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>gmp_div_q</function>, <function>gmp_div_qr</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -312,39 +320,41 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>array <function>gmp_div_qr</function></funcdef>
|
||||
<paramdef>resource <parameter>n</parameter></paramdef>
|
||||
<paramdef>resource <parameter>d</parameter></paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>round</optional></parameter>
|
||||
</paramdef>
|
||||
<paramdef>resource <parameter>n</parameter></paramdef>
|
||||
<paramdef>resource <parameter>d</parameter></paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>round</optional></parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
The function divides <parameter>n</parameter> by
|
||||
<parameter>d</parameter> and returns array, with the first element being
|
||||
<literal>[n/d]</literal> (the integer result of the
|
||||
division) and the second being <literal>(n - [n/d] * d)</literal>
|
||||
(the remainder of the division).
|
||||
The function divides <parameter>n</parameter> by
|
||||
<parameter>d</parameter> and returns array, with the first
|
||||
element being <literal>[n/d]</literal> (the integer result of the
|
||||
division) and the second being <literal>(n - [n/d] * d)</literal>
|
||||
(the remainder of the division).
|
||||
</para>
|
||||
<para>
|
||||
See the <function>gmp_div_q</function> function for description
|
||||
of the <parameter>round</parameter> argument.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Division of GMP numbers</title>
|
||||
<programlisting role="php">
|
||||
See the <function>gmp_div_q</function> function for description
|
||||
of the <parameter>round</parameter> argument.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Division of GMP numbers</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$a = gmp_init("0x41682179fbf5");
|
||||
$res = gmp_div_qr($a, "0xDEFE75");
|
||||
printf("Result is: q - %s, r - %s", gmp_strval($res[0]), gmp_strval($res[1]));
|
||||
$a = gmp_init ("0x41682179fbf5");
|
||||
$res = gmp_div_qr ($a, "0xDEFE75");
|
||||
printf("Result is: q - %s, r - %s",
|
||||
gmp_strval ($res[0]), gmp_strval ($res[1]));
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>gmp_div_q</function>, <function>gmp_div_r</function>.
|
||||
</para>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>gmp_div_q</function>,
|
||||
<function>gmp_div_r</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -358,12 +368,12 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_divexact</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
This function is an alias to <function>gmp_div_q</function>.
|
||||
This function is an alias to <function>gmp_div_q</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -378,14 +388,14 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_mod</function></funcdef>
|
||||
<paramdef>resource <parameter>n</parameter></paramdef>
|
||||
<paramdef>resource <parameter>d</parameter></paramdef>
|
||||
<paramdef>resource <parameter>n</parameter></paramdef>
|
||||
<paramdef>resource <parameter>d</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates <parameter>n</parameter> modulo
|
||||
<parameter>d</parameter>. The result is always non-negative, the
|
||||
sign of <parameter>d</parameter> is ignored.
|
||||
Calculates <parameter>n</parameter> modulo
|
||||
<parameter>d</parameter>. The result is always non-negative, the
|
||||
sign of <parameter>d</parameter> is ignored.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -400,20 +410,20 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_divexact</function></funcdef>
|
||||
<paramdef>resource <parameter>n</parameter></paramdef>
|
||||
<paramdef>resource <parameter>d</parameter></paramdef>
|
||||
<paramdef>resource <parameter>n</parameter></paramdef>
|
||||
<paramdef>resource <parameter>d</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Divides <parameter>n</parameter> by <parameter>d</parameter>,
|
||||
using fast "exact division" algorithm. This function produces
|
||||
correct results only when it is known in advance that
|
||||
<parameter>d</parameter> divides <parameter>n</parameter>.
|
||||
Divides <parameter>n</parameter> by <parameter>d</parameter>,
|
||||
using fast "exact division" algorithm. This function produces
|
||||
correct results only when it is known in advance that
|
||||
<parameter>d</parameter> divides <parameter>n</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.gmp-cmp">
|
||||
<refentry id="function.gmp-cmp">
|
||||
<refnamediv>
|
||||
<refname>gmp_cmp</refname>
|
||||
<refpurpose>Compare numbers</refpurpose>
|
||||
|
@ -423,13 +433,14 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_cmp</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns positive value if <literal>a > b</literal>, zero if
|
||||
<literal>a = b</literal> and negative value if <literal>a < b</literal>.
|
||||
Returns positive value if <literal>a > b</literal>, zero if
|
||||
<literal>a = b</literal> and negative value if <literal>a <
|
||||
b</literal>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -444,11 +455,11 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_neg</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns -<parameter>a</parameter>.
|
||||
Returns -<parameter>a</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -463,11 +474,11 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_abs</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns absolute value of <parameter>a</parameter>.
|
||||
Returns absolute value of <parameter>a</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -486,8 +497,8 @@ rounded towards <literal>-infinity</literal>.
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Return sign of <parameter>a</parameter> - 1 if
|
||||
<parameter>a</parameter> is positive and -1 if it's negative.
|
||||
Return sign of <parameter>a</parameter> - 1 if
|
||||
<parameter>a</parameter> is positive and -1 if it's negative.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -502,11 +513,11 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_fact</function></funcdef>
|
||||
<paramdef>int <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter>a</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates factorial (<literal>a!</literal>) of <parameter>a</parameter>.
|
||||
Calculates factorial (<literal>a!</literal>) of <parameter>a</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -525,7 +536,7 @@ rounded towards <literal>-infinity</literal>.
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates square root of <parameter>a</parameter>.
|
||||
Calculates square root of <parameter>a</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -540,14 +551,15 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>array <function>gmp_sqrtrm</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns array where first element is the integer square root of
|
||||
<parameter>a</parameter> (see also <function>gmp_sqrt</function>), and
|
||||
the second is the remainder (i.e., the difference between
|
||||
<parameter>a</parameter> and the first element squared).
|
||||
Returns array where first element is the integer square root of
|
||||
<parameter>a</parameter> (see also
|
||||
<function>gmp_sqrt</function>), and the second is the remainder
|
||||
(i.e., the difference between <parameter>a</parameter> and the
|
||||
first element squared).
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -562,17 +574,17 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>gmp_perfect_square</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>a</parameter> is a prefect square,
|
||||
false otherwise.
|
||||
Returns true if <parameter>a</parameter> is a prefect square,
|
||||
false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
See also: <function>gmp_sqrt</function>,
|
||||
<function>gmp_sqrtrm</function>.
|
||||
</para>
|
||||
<para>
|
||||
See also: <function>gmp_sqrt</function>,
|
||||
<function>gmp_sqrtrm</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -586,14 +598,14 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_pow</function></funcdef>
|
||||
<paramdef>resource <parameter>base</parameter></paramdef>
|
||||
<paramdef>int <parameter>exp</parameter></paramdef>
|
||||
<paramdef>resource <parameter>base</parameter></paramdef>
|
||||
<paramdef>int <parameter>exp</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Raise <parameter>base</parameter> into power
|
||||
<parameter>exp</parameter>. The case of 0^0 yields
|
||||
1. <parameter>exp</parameter> cannot be negative.
|
||||
Raise <parameter>base</parameter> into power
|
||||
<parameter>exp</parameter>. The case of 0^0 yields
|
||||
1. <parameter>exp</parameter> cannot be negative.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -608,15 +620,15 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_powm</function></funcdef>
|
||||
<paramdef>resource <parameter>base</parameter></paramdef>
|
||||
<paramdef>resource <parameter>exp</parameter></paramdef>
|
||||
<paramdef>resource <parameter>mod</parameter></paramdef>
|
||||
<paramdef>resource <parameter>base</parameter></paramdef>
|
||||
<paramdef>resource <parameter>exp</parameter></paramdef>
|
||||
<paramdef>resource <parameter>mod</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculate (<parameter>base</parameter> raised into power
|
||||
<parameter>exp</parameter>) modulo <parameter>mod</parameter>. If
|
||||
<parameter>exp</parameter> is negative, result is undefined.
|
||||
Calculate (<parameter>base</parameter> raised into power
|
||||
<parameter>exp</parameter>) modulo <parameter>mod</parameter>. If
|
||||
<parameter>exp</parameter> is negative, result is undefined.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -631,21 +643,22 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_prob_prime</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter><optional>reps</optional></parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter><optional>reps</optional></parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
If this function returns 0, <parameter>a</parameter> is definitely
|
||||
not prime. If it returns 1, then <parameter>a</parameter> is
|
||||
"probably" prime. If it returns 2, then <parameter>a</parameter> is
|
||||
surely prime. Reasonable values of <parameter>reps</parameter>
|
||||
vary from 5 to 10 (default being 10); a higher value lowers the
|
||||
probability for a non-prime to pass as a "probable" prime.
|
||||
If this function returns 0, <parameter>a</parameter> is
|
||||
definitely not prime. If it returns 1, then
|
||||
<parameter>a</parameter> is "probably" prime. If it returns 2,
|
||||
then <parameter>a</parameter> is surely prime. Reasonable values
|
||||
of <parameter>reps</parameter> vary from 5 to 10 (default being
|
||||
10); a higher value lowers the probability for a non-prime to
|
||||
pass as a "probable" prime.
|
||||
</para>
|
||||
<para>
|
||||
<para>
|
||||
The function uses Miller-Rabin's probabilistic test.
|
||||
</para>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -664,9 +677,9 @@ rounded towards <literal>-infinity</literal>.
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculate greatest common divisor of <parameter>a</parameter> and
|
||||
<parameter>b</parameter>. The result is always positive even if
|
||||
either of or both input operands are negative.
|
||||
Calculate greatest common divisor of <parameter>a</parameter> and
|
||||
<parameter>b</parameter>. The result is always positive even if
|
||||
either of or both input operands are negative.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -681,14 +694,14 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>array <function>gmp_gcdext</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates g, s, and t, such that
|
||||
<literal>a*s + b*t = g = gcd(a,b)</literal>, where gcd is gretest
|
||||
common divisor. Returns array with respective elements g, s and t.
|
||||
Calculates g, s, and t, such that <literal>a*s + b*t = g =
|
||||
gcd(a,b)</literal>, where gcd is gretest common divisor. Returns
|
||||
array with respective elements g, s and t.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -703,13 +716,14 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_invert</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Computes the inverse of <parameter>a</parameter> modulo
|
||||
<parameter>b</parameter>. Returns false if an inverse does not exist.
|
||||
Computes the inverse of <parameter>a</parameter> modulo
|
||||
<parameter>b</parameter>. Returns false if an inverse does not
|
||||
exist.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -724,16 +738,16 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_legendre</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>p</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>p</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Compute the
|
||||
<ulink url="http://www.utm.edu/research/primes/glossary/LegendreSymbol.html">
|
||||
Legendre symbol</ulink> of <parameter>a</parameter> and
|
||||
<parameter>p</parameter>. <parameter>p</parameter> should be odd
|
||||
and must be positive.
|
||||
Compute the
|
||||
<ulink url="http://www.utm.edu/research/primes/glossary/LegendreSymbol.html">
|
||||
Legendre symbol</ulink> of <parameter>a</parameter> and
|
||||
<parameter>p</parameter>. <parameter>p</parameter> should be odd
|
||||
and must be positive.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -748,17 +762,16 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_jacobi</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>p</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>p</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Computes
|
||||
<ulink
|
||||
url="http://www.utm.edu/research/primes/glossary/JacobiSymbol.html">
|
||||
Jacobi symbol</ulink> of <parameter>a</parameter> and
|
||||
<parameter>p</parameter>. <parameter>p</parameter> should be odd
|
||||
and must be positive.
|
||||
Computes
|
||||
<ulink url="http://www.utm.edu/research/primes/glossary/JacobiSymbol.html">
|
||||
Jacobi symbol</ulink> of <parameter>a</parameter> and
|
||||
<parameter>p</parameter>. <parameter>p</parameter> should be odd
|
||||
and must be positive.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -773,13 +786,14 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_random</function></funcdef>
|
||||
<paramdef>int <parameter>limiter</parameter></paramdef>
|
||||
<paramdef>int <parameter>limiter</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Generate a random number. The number will be up to
|
||||
<parameter>limiter</parameter> words long. If
|
||||
<parameter>limiter</parameter> is negative, negative numbers are generated.
|
||||
Generate a random number. The number will be up to
|
||||
<parameter>limiter</parameter> words long. If
|
||||
<parameter>limiter</parameter> is negative, negative numbers are
|
||||
generated.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -794,12 +808,12 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_and</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates logical AND of two GMP numbers.
|
||||
Calculates logical AND of two GMP numbers.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -814,12 +828,12 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_or</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates logical inclusive OR of two GMP numbers.
|
||||
Calculates logical inclusive OR of two GMP numbers.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -834,12 +848,12 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_xor</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Calculates logical exclusive OR (XOR) of two GMP numbers.
|
||||
Calculates logical exclusive OR (XOR) of two GMP numbers.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -854,15 +868,18 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_setbit</function></funcdef>
|
||||
<paramdef>resource <parameter>&a</parameter></paramdef>
|
||||
<paramdef>int <parameter>index</parameter></paramdef>
|
||||
<paramdef>bool <parameter><optional>set_clear</optional></parameter></paramdef>
|
||||
<paramdef>resource <parameter>&a</parameter></paramdef>
|
||||
<paramdef>int <parameter>index</parameter></paramdef>
|
||||
<paramdef>bool
|
||||
<parameter><optional>set_clear</optional></parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Sets bit <parameter>index</parameter> in
|
||||
<parameter>a</parameter>. <parameter>set_clear</parameter> defines
|
||||
if the bit is set to 0 or 1. By default the bit is set to 1.
|
||||
Sets bit <parameter>index</parameter> in
|
||||
<parameter>a</parameter>. <parameter>set_clear</parameter>
|
||||
defines if the bit is set to 0 or 1. By default the bit is set to
|
||||
1.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -877,13 +894,13 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>resource <function>gmp_clrbit</function></funcdef>
|
||||
<paramdef>resource <parameter>&a</parameter></paramdef>
|
||||
<paramdef>int <parameter>index</parameter></paramdef>
|
||||
<paramdef>resource <parameter>&a</parameter></paramdef>
|
||||
<paramdef>int <parameter>index</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Clears (sets to 0) bit <parameter>index</parameter> in
|
||||
<parameter>a</parameter>.
|
||||
Clears (sets to 0) bit <parameter>index</parameter> in
|
||||
<parameter>a</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -898,15 +915,15 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_scan0</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter>start</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter>start</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Scans <parameter>a</parameter>, starting with bit
|
||||
<parameter>start</parameter>, towards more significant
|
||||
bits, until the first clear bit is found. Returns the index of the
|
||||
found bit.
|
||||
Scans <parameter>a</parameter>, starting with bit
|
||||
<parameter>start</parameter>, towards more significant bits,
|
||||
until the first clear bit is found. Returns the index of the
|
||||
found bit.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -921,20 +938,20 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_scan1</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter>start</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>int <parameter>start</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Scans <parameter>a</parameter>, starting with bit
|
||||
<parameter>start</parameter>, towards more significant
|
||||
bits, until the first set bit is found. Returns the index of the
|
||||
found bit.
|
||||
Scans <parameter>a</parameter>, starting with bit
|
||||
<parameter>start</parameter>, towards more significant bits,
|
||||
until the first set bit is found. Returns the index of the found
|
||||
bit.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.gmp-popcount">
|
||||
<refentry id="function.gmp-popcount">
|
||||
<refnamediv>
|
||||
<refname>gmp_popcount</refname>
|
||||
<refpurpose>Population count</refpurpose>
|
||||
|
@ -944,11 +961,11 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_popcount</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Return the population count of <parameter>a</parameter>.
|
||||
Return the population count of <parameter>a</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -963,13 +980,13 @@ rounded towards <literal>-infinity</literal>.
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>gmp_hamdist</function></funcdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
<paramdef>resource <parameter>a</parameter></paramdef>
|
||||
<paramdef>resource <parameter>b</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns the hamming distance between <parameter>a</parameter> and
|
||||
<parameter>a</parameter>. Both operands should be non-negative.
|
||||
Returns the hamming distance between <parameter>a</parameter> and
|
||||
<parameter>a</parameter>. Both operands should be non-negative.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue