dave Sun Feb 8 03:46:26 2004 EDT
Modified files:
/phpdoc/en/reference/gmp/functions gmp-abs.xml gmp-add.xml
gmp-and.xml gmp-clrbit.xml
gmp-cmp.xml gmp-com.xml
gmp-div-q.xml gmp-div-r.xml
gmp-divexact.xml gmp-fact.xml
gmp-gcd.xml gmp-hamdist.xml
gmp-intval.xml gmp-invert.xml
gmp-jacobi.xml gmp-legendre.xml
gmp-mod.xml gmp-mul.xml
gmp-neg.xml gmp-or.xml
gmp-perfect-square.xml
gmp-popcount.xml gmp-pow.xml
gmp-powm.xml gmp-prob-prime.xml
gmp-random.xml gmp-scan0.xml
gmp-scan1.xml gmp-setbit.xml
gmp-sign.xml gmp-sqrt.xml
gmp-sqrtrem.xml gmp-sub.xml
gmp-xor.xml
Log:
- Add GMP function examples, and fix a few problems.
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-abs.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-abs.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-abs.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-abs.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-abs.xml:1.2 Wed Apr 17 02:38:22 2002
+++ phpdoc/en/reference/gmp/functions/gmp-abs.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-abs">
<refnamediv>
@@ -15,6 +15,29 @@
<para>
Returns absolute value of <parameter>a</parameter>.
</para>
+ <example>
+ <title><function>gmp_abs</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $abs1 = gmp_abs("274982683358");
+ $abs2 = gmp_abs("-274982683358");
+
+ echo gmp_strval($abs1) . "\n";
+ echo gmp_strval($abs2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+274982683358
+274982683358
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-add.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-add.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-add.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-add.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-add.xml:1.2 Wed Apr 17 02:38:23 2002
+++ phpdoc/en/reference/gmp/functions/gmp-add.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-add">
<refnamediv>
@@ -17,6 +17,25 @@
Add two GMP numbers. The result will be a GMP number representing
the sum of the arguments.
</para>
+ <example>
+ <title><function>gmp_add</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $sum = gmp_add("123456789012345", "76543210987655");
+ echo gmp_strval($sum) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+200000000000000
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-and.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-and.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-and.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-and.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-and.xml:1.2 Wed Apr 17 02:38:23 2002
+++ phpdoc/en/reference/gmp/functions/gmp-and.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-and">
<refnamediv>
@@ -16,6 +16,26 @@
<para>
Calculates logical AND of two GMP numbers.
</para>
+ <example>
+ <title><function>gmp_and</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+ $and1 = gmp_and("0xfffffffff4", "0x4");
+ $and2 = gmp_and("0xfffffffff4", "0x8");
+ echo gmp_strval($and1) . "\n";
+ echo gmp_strval($and2) . "\n";
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+4
+0
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-clrbit.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-clrbit.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-clrbit.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-clrbit.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-clrbit.xml:1.2 Wed Apr 17 02:38:23
2002
+++ phpdoc/en/reference/gmp/functions/gmp-clrbit.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-clrbit">
<refnamediv>
@@ -9,13 +9,42 @@
<refsect1>
<title>Description</title>
<methodsynopsis>
- <type>resource</type><methodname>gmp_clrbit</methodname>
+ <type>void</type><methodname>gmp_clrbit</methodname>
<methodparam><type>resource</type><parameter>&a</parameter></methodparam>
<methodparam><type>int</type><parameter>index</parameter></methodparam>
</methodsynopsis>
<para>
Clears (sets to 0) bit <parameter>index</parameter> in
- <parameter>a</parameter>.
+ <parameter>a</parameter>. The index starts at 0.
+ </para>
+ <note>
+ <para>
+ Unlike most of the other GMP functions, <function>gmp_clrbit</function>
+ must be called with a GMP resource that already exists (using
+ <function>gmp_init</function> for example). One will not be
+ automatically created.
+ </para>
+ </note>
+ <example>
+ <title><function>gmp_clrbit</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+ $a = gmp_init("0xff");
+ gmp_clrbit($a, 0); // index starts at 0, least significant bit
+ echo gmp_strval($a) . "\n";
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+254
+]]>
+ </screen>
+ </example>
+ <para>
+ See also <function>gmp_setbit</function>.
</para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-cmp.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-cmp.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-cmp.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-cmp.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-cmp.xml:1.2 Wed Apr 17 02:38:23 2002
+++ phpdoc/en/reference/gmp/functions/gmp-cmp.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-cmp">
<refnamediv>
@@ -14,10 +14,32 @@
<methodparam><type>resource</type><parameter>b</parameter></methodparam>
</methodsynopsis>
<para>
- Returns a positive value if <literal>a > b</literal>, zero if
- <literal>a = b</literal> and negative value if <literal>a <
+ Returns a positive value if <literal>a > b</literal>, zero if
+ <literal>a = b</literal> and a negative value if <literal>a <
b</literal>.
</para>
+ <example>
+ <title><function>gmp_cmp</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $cmp1 = gmp_cmp("1234", "1000"); // greater than
+ $cmp2 = gmp_cmp("1000", "1234"); // less than
+ $cmp3 = gmp_cmp("1234", "1234"); // equal to
+
+ echo "$cmp1 $cmp2 $cmp3\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+1 -1 0
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-com.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-com.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-com.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-com.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-com.xml:1.2 Wed Apr 17 02:38:23 2002
+++ phpdoc/en/reference/gmp/functions/gmp-com.xml Sun Feb 8 03:46:22 2004
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.20 -->
<refentry id='function.gmp-com'>
<refnamediv>
<refname>gmp_com</refname>
- <refpurpose>Calculates one's complement of a</refpurpose>
+ <refpurpose>Calculates one's complement</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -13,8 +13,28 @@
<methodparam><type>resource</type><parameter>a</parameter></methodparam>
</methodsynopsis>
<para>
- &warn.undocumented.func;
+ Returns the one's complement of <parameter>a</parameter>.
</para>
+ <example>
+ <title><function>gmp_com</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $com = gmp_com("1234");
+ echo gmp_strval($com) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+-1235
+]]>
+ </screen>
+ </example>
+
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-div-q.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-div-q.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-div-q.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-div-q.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-div-q.xml:1.2 Wed Apr 17 02:38:24 2002
+++ phpdoc/en/reference/gmp/functions/gmp-div-q.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-div-q">
<refnamediv>
@@ -43,6 +43,41 @@
<simpara>
This function can also be called as <function>gmp_div</function>.
</simpara>
+ <example>
+ <title><function>gmp_div_q</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $div1 = gmp_div_q("100", "5");
+ echo gmp_strval($div1) . "\n";
+
+ $div2 = gmp_div_q("1", "3");
+ echo gmp_strval($div2) . "\n";
+
+ $div3 = gmp_div_q("1", "3", GMP_ROUND_PLUSINF);
+ echo gmp_strval($div3) . "\n";
+
+ $div4 = gmp_div_q("-1", "4", GMP_ROUND_PLUSINF);
+ echo gmp_strval($div4) . "\n";
+
+ $div5 = gmp_div_q("-1", "4", GMP_ROUND_MINUSINF);
+ echo gmp_strval($div5) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+20
+0
+1
+0
+1
+]]>
+ </screen>
+ </example>
<para>
See also <function>gmp_div_r</function>,
<function>gmp_div_qr</function>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-div-r.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-div-r.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-div-r.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-div-r.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-div-r.xml:1.2 Wed Apr 17 02:38:24 2002
+++ phpdoc/en/reference/gmp/functions/gmp-div-r.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-div-r">
<refnamediv>
@@ -20,6 +20,25 @@
remainder has the sign of the <parameter>n</parameter> argument,
if not zero.
</para>
+ <example>
+ <title><function>gmp_div_r</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $div = gmp_div_r("105", "20");
+ echo gmp_strval($div) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+5
+]]>
+ </screen>
+ </example>
<para>
See the <function>gmp_div_q</function> function for description
of the <parameter>round</parameter> argument.
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-divexact.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-divexact.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-divexact.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-divexact.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-divexact.xml:1.2 Wed Apr 17 02:38:24
2002
+++ phpdoc/en/reference/gmp/functions/gmp-divexact.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-divexact">
<refnamediv>
@@ -19,6 +19,29 @@
correct results only when it is known in advance that
<parameter>d</parameter> divides <parameter>n</parameter>.
</para>
+ <example>
+ <title><function>gmp_divexact</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $div1 = gmp_divexact("10", "2");
+ echo gmp_strval($div1) . "\n";
+
+ $div2 = gmp_divexact("10", "3"); // bogus result
+ echo gmp_strval($div2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+5
+2863311534
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-fact.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-fact.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-fact.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-fact.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-fact.xml:1.2 Wed Apr 17 02:38:24 2002
+++ phpdoc/en/reference/gmp/functions/gmp-fact.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-fact">
<refnamediv>
@@ -15,6 +15,29 @@
<para>
Calculates factorial (<literal>a!</literal>) of <parameter>a</parameter>.
</para>
+ <example>
+ <title><function>gmp_fact</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $fact1 = gmp_fact(5); // 5 * 4 * 3 * 2 * 1
+ echo gmp_strval($fact1) . "\n";
+
+ $fact2 = gmp_fact(50); // 50 * 49 * 48, ... etc
+ echo gmp_strval($fact2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+120
+30414093201713378043612608166064768844377641568960512000000000000
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-gcd.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-gcd.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-gcd.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-gcd.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-gcd.xml:1.2 Wed Apr 17 02:38:24 2002
+++ phpdoc/en/reference/gmp/functions/gmp-gcd.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-gcd">
<refnamediv>
@@ -18,6 +18,25 @@
<parameter>b</parameter>. The result is always positive even if
either of, or both, input operands are negative.
</para>
+ <example>
+ <title><function>gmp_gcd</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $gcd = gmp_gcd("12", "21");
+ echo gmp_strval($gcd) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+3
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-hamdist.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-hamdist.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-hamdist.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-hamdist.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-hamdist.xml:1.2 Wed Apr 17 02:38:24
2002
+++ phpdoc/en/reference/gmp/functions/gmp-hamdist.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-hamdist">
<refnamediv>
@@ -17,6 +17,34 @@
Returns the hamming distance between <parameter>a</parameter> and
<parameter>b</parameter>. Both operands should be non-negative.
</para>
+ <example>
+ <title><function>gmp_hamdist</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $ham1 = gmp_init("1001010011", 2);
+ $ham2 = gmp_init("1011111100", 2);
+ echo gmp_hamdist($ham1, $ham2) . "\n";
+
+ /* hamdist is equivilent to: */
+ echo gmp_popcount(gmp_xor($ham1, $ham2)) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+6
+6
+]]>
+ </screen>
+ </example>
+ <para>
+ See also <function>gmp_popcount</function>,
+ <function>gmp_xor</function>
+ </para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-intval.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-intval.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-intval.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-intval.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-intval.xml:1.2 Wed Apr 17 02:38:24
2002
+++ phpdoc/en/reference/gmp/functions/gmp-intval.xml Sun Feb 8 03:46:22 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-intval">
<refnamediv>
@@ -22,6 +22,33 @@
</simpara>
</warning>
</para>
+ <example>
+ <title><function>gmp_intval</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ // displays correct result
+ echo gmp_intval("2147483647") . "\n";
+
+ // displays wrong result, above PHP integer limit
+ echo gmp_intval("2147483648") . "\n";
+
+ // displays correct result
+ echo gmp_strval("2147483648") . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+2147483647
+2147483647
+2147483648
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-invert.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-invert.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-invert.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-invert.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-invert.xml:1.2 Wed Apr 17 02:38:25
2002
+++ phpdoc/en/reference/gmp/functions/gmp-invert.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-invert">
<refnamediv>
@@ -18,6 +18,26 @@
<parameter>b</parameter>. Returns &false; if an inverse does not
exist.
</para>
+ <example>
+ <title><function>gmp_invert</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ echo gmp_invert("5", "10"); // no inverse, outputs nothing, result is FALSE
+ $invert = gmp_invert("5", "11");
+ echo gmp_strval($invert) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+9
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-jacobi.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-jacobi.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-jacobi.xml:1.3
phpdoc/en/reference/gmp/functions/gmp-jacobi.xml:1.4
--- phpdoc/en/reference/gmp/functions/gmp-jacobi.xml:1.3 Sat Jul 5 10:52:05
2003
+++ phpdoc/en/reference/gmp/functions/gmp-jacobi.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-jacobi">
<refnamediv>
@@ -20,6 +20,26 @@
<parameter>p</parameter>. <parameter>p</parameter> should be odd
and must be positive.
</para>
+ <example>
+ <title><function>gmp_jacobi</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ echo gmp_jacobi("1", "3") . "\n";
+ echo gmp_jacobi("2", "3") . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+1
+0
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-legendre.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-legendre.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-legendre.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-legendre.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-legendre.xml:1.2 Wed Apr 17 02:38:25
2002
+++ phpdoc/en/reference/gmp/functions/gmp-legendre.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-legendre">
<refnamediv>
@@ -20,6 +20,26 @@
<parameter>p</parameter>. <parameter>p</parameter> should be odd
and must be positive.
</para>
+ <example>
+ <title><function>gmp_legendre</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ echo gmp_legendre("1", "3") . "\n";
+ echo gmp_legendre("2", "3") . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+1
+0
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-mod.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-mod.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-mod.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-mod.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-mod.xml:1.2 Wed Apr 17 02:38:25 2002
+++ phpdoc/en/reference/gmp/functions/gmp-mod.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-mod">
<refnamediv>
@@ -18,6 +18,25 @@
<parameter>d</parameter>. The result is always non-negative, the
sign of <parameter>d</parameter> is ignored.
</para>
+ <example>
+ <title><function>gmp_mod</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $mod = gmp_mod("8", "3");
+ echo gmp_strval($mod) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+2
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-mul.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-mul.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-mul.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-mul.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-mul.xml:1.2 Wed Apr 17 02:38:25 2002
+++ phpdoc/en/reference/gmp/functions/gmp-mul.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-mul">
<refnamediv>
@@ -17,6 +17,25 @@
Multiplies <parameter>a</parameter> by <parameter>b</parameter>
and returns the result.
</para>
+ <example>
+ <title><function>gmp_mul</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $mul = gmp_mul("12345678", "2000");
+ echo gmp_strval($mul) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+24691356000
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-neg.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-neg.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-neg.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-neg.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-neg.xml:1.2 Wed Apr 17 02:38:25 2002
+++ phpdoc/en/reference/gmp/functions/gmp-neg.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-neg">
<refnamediv>
@@ -15,6 +15,28 @@
<para>
Returns -<parameter>a</parameter>.
</para>
+ <example>
+ <title><function>gmp_neg</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $neg1 = gmp_neg("1"); //
+ echo gmp_strval($neg1) . "\n";
+ $neg2 = gmp_neg("-1"); //
+ echo gmp_strval($neg2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+-1
+1
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-or.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-or.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-or.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-or.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-or.xml:1.2 Wed Apr 17 02:38:25 2002
+++ phpdoc/en/reference/gmp/functions/gmp-or.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-or">
<refnamediv>
@@ -16,6 +16,28 @@
<para>
Calculates logical inclusive OR of two GMP numbers.
</para>
+ <example>
+ <title><function>gmp_or</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $or1 = gmp_or("0xfffffff2", "4");
+ echo gmp_strval($or1, 16) . "\n";
+ $or2 = gmp_or("0xfffffff2", "2");
+ echo gmp_strval($or2, 16) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+fffffff6
+fffffff2
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-perfect-square.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-perfect-square.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-perfect-square.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-perfect-square.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-perfect-square.xml:1.2 Wed Apr 17
02:38:25 2002
+++ phpdoc/en/reference/gmp/functions/gmp-perfect-square.xml Sun Feb 8 03:46:23
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-perfect-square">
<refnamediv>
@@ -16,6 +16,33 @@
Returns &true; if <parameter>a</parameter> is a perfect square,
&false; otherwise.
</para>
+ <example>
+ <title><function>gmp_perfect_square</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ // 3 * 3, perfect square
+ var_dump(gmp_perfect_square("9"));
+
+ // not a perfect square
+ var_dump(gmp_perfect_square("7"));
+
+ // 1234567890 * 1234567890, perfect square
+ var_dump(gmp_perfect_square("1524157875019052100"));
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+bool(true)
+bool(false)
+bool(true)
+]]>
+ </screen>
+ </example>
<para>
See also: <function>gmp_sqrt</function>,
<function>gmp_sqrtrm</function>.
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-popcount.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-popcount.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-popcount.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-popcount.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-popcount.xml:1.2 Wed Apr 17 02:38:26
2002
+++ phpdoc/en/reference/gmp/functions/gmp-popcount.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-popcount">
<refnamediv>
@@ -15,6 +15,28 @@
<para>
Return the population count of <parameter>a</parameter>.
</para>
+ <example>
+ <title><function>gmp_popcount</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $pop1 = gmp_init("10000101", 2); // 3 1's
+ echo gmp_popcount($pop1) . "\n";
+ $pop2 = gmp_init("11111110", 2); // 7 1's
+ echo gmp_popcount($pop2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+3
+7
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-pow.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-pow.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-pow.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-pow.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-pow.xml:1.2 Wed Apr 17 02:38:26 2002
+++ phpdoc/en/reference/gmp/functions/gmp-pow.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-pow">
<refnamediv>
@@ -18,6 +18,30 @@
<parameter>exp</parameter>. The case of 0^0 yields
1. <parameter>exp</parameter> cannot be negative.
</para>
+ <example>
+ <title><function>gmp_pow</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $pow1 = gmp_pow("2", 31);
+ echo gmp_strval($pow1) . "\n";
+ $pow2 = gmp_pow("0", 0);
+ echo gmp_strval($pow2) . "\n";
+ $pow3 = gmp_pow("2", -1); // Negative exp, generates warning
+ echo gmp_strval($pow3) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+2147483648
+1
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-powm.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-powm.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-powm.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-powm.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-powm.xml:1.2 Wed Apr 17 02:38:26 2002
+++ phpdoc/en/reference/gmp/functions/gmp-powm.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-powm">
<refnamediv>
@@ -19,6 +19,25 @@
<parameter>exp</parameter>) modulo <parameter>mod</parameter>. If
<parameter>exp</parameter> is negative, result is undefined.
</para>
+ <example>
+ <title><function>gmp_powm</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $pow1 = gmp_powm("2", "31", "2147483649");
+ echo gmp_strval($pow1) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+2147483648
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-prob-prime.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-prob-prime.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-prob-prime.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-prob-prime.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-prob-prime.xml:1.2 Wed Apr 17 02:38:26
2002
+++ phpdoc/en/reference/gmp/functions/gmp-prob-prime.xml Sun Feb 8 03:46:23
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-prob-prime">
<refnamediv>
@@ -25,6 +25,33 @@
<para>
The function uses Miller-Rabin's probabilistic test.
</para>
+ <example>
+ <title><function>gmp_prob_prime</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ // definitely not a prime
+ echo gmp_prob_prime("6") . "\n";
+
+ // probably a prime
+ echo gmp_prob_prime("1111111111111111111") . "\n";
+
+ // definitely a prime
+ echo gmp_prob_prime("11") . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+0
+1
+2
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-random.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-random.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-random.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-random.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-random.xml:1.2 Wed Apr 17 02:38:26
2002
+++ phpdoc/en/reference/gmp/functions/gmp-random.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-random">
<refnamediv>
@@ -14,10 +14,38 @@
</methodsynopsis>
<para>
Generate a random number. The number will be between
- <parameter>limiter</parameter> and zero in value. If
- <parameter>limiter</parameter> is negative, negative numbers are
- generated.
+ zero and the number of bits per limb multiplied by
+ <parameter>limiter</parameter>. If <parameter>limiter</parameter>
+ is negative, negative numbers are generated.
</para>
+ <para>
+ A limb is an internal GMP mechanism. The number of bits in a limb is
+ not static, and can vary from system to system. Generally, the number
+ of bits in a limb is either 16 or 32, but this is not guaranteed.
+ </para>
+ <example>
+ <title><function>gmp_random</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $rand1 = gmp_random(1); // random number from 0 to 1 * bits per limb
+ $rand2 = gmp_random(2); // random number from 0 to 2 * bits per limb
+
+ echo gmp_strval($rand1) . "\n";
+ echo gmp_strval($rand2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program might be:
+ </para>
+ <screen>
+<![CDATA[
+1915834968
+8642564075890328087
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-scan0.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-scan0.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-scan0.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-scan0.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-scan0.xml:1.2 Wed Apr 17 02:38:26 2002
+++ phpdoc/en/reference/gmp/functions/gmp-scan0.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-scan0">
<refnamediv>
@@ -17,8 +17,33 @@
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.
+ found bit. The index starts from 0.
</para>
+ <example>
+ <title><function>gmp_scan0</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ // "0" bit is found at position 3. index starts at 0
+ $s1 = gmp_init("10111", 2);
+ echo gmp_scan0($s1, 0) . "\n";
+
+ // "0" bit is found at position 7. index starts at 5
+ $s2 = gmp_init("101110000", 2);
+ echo gmp_scan0($s2, 5) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+3
+7
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-scan1.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-scan1.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-scan1.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-scan1.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-scan1.xml:1.2 Wed Apr 17 02:38:26 2002
+++ phpdoc/en/reference/gmp/functions/gmp-scan1.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-scan1">
<refnamediv>
@@ -19,6 +19,31 @@
until the first set bit is found. Returns the index of the found
bit.
</para>
+ <example>
+ <title><function>gmp_scan1</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ // "1" bit is found at position 3. index starts at 0
+ $s1 = gmp_init("01000", 2);
+ echo gmp_scan1($s1, 0) . "\n";
+
+ // "1" bit is found at position 9. index starts at 5
+ $s2 = gmp_init("01000001111", 2);
+ echo gmp_scan1($s2, 5) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+3
+9
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-setbit.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-setbit.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-setbit.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-setbit.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-setbit.xml:1.2 Wed Apr 17 02:38:26
2002
+++ phpdoc/en/reference/gmp/functions/gmp-setbit.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-setbit">
<refnamediv>
@@ -9,7 +9,7 @@
<refsect1>
<title>Description</title>
<methodsynopsis>
- <type>resource</type><methodname>gmp_setbit</methodname>
+ <type>void</type><methodname>gmp_setbit</methodname>
<methodparam><type>resource</type><parameter>&a</parameter></methodparam>
<methodparam><type>int</type><parameter>index</parameter></methodparam>
<methodparam
choice="opt"><type>bool</type><parameter>set_clear</parameter></methodparam>
@@ -18,7 +18,38 @@
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.
+ 1. Index
+ </para>
+ <note>
+ <para>
+ Unlike most of the other GMP functions, <function>gmp_setbit</function>
+ must be called with a GMP resource that already exists (using
+ <function>gmp_init</function> for example). One will not be
+ automatically created.
+ </para>
+ </note>
+ <example>
+ <title><function>gmp_setbit</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $a = gmp_init("0xfd");
+ gmp_setbit($a, 1); // index starts at 0
+ echo gmp_strval($a) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+255
+]]>
+ </screen>
+ </example>
+ <para>
+ See also <function>gmp_clrbit</function>.
</para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-sign.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-sign.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-sign.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-sign.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-sign.xml:1.2 Wed Apr 17 02:38:26 2002
+++ phpdoc/en/reference/gmp/functions/gmp-sign.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-sign">
<refnamediv>
@@ -13,9 +13,37 @@
<methodparam><type>resource</type><parameter>a</parameter></methodparam>
</methodsynopsis>
<para>
- Return sign of <parameter>a</parameter> - 1 if
- <parameter>a</parameter> is positive and -1 if it's negative.
+ Returns 1 if <parameter>a</parameter> is positive,
+ -1 if <parameter>a</parameter> is negative,
+ and 0 if <parameter>a</parameter> is zero.
</para>
+ <example>
+ <title><function>gmp_sign</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ // positive
+ echo gmp_sign("500") . "\n";
+
+ // negative
+ echo gmp_sign("-500") . "\n";
+
+ // zero
+ echo gmp_sign("0") . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+1
+-1
+0
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-sqrt.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-sqrt.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-sqrt.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-sqrt.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-sqrt.xml:1.2 Wed Apr 17 02:38:27 2002
+++ phpdoc/en/reference/gmp/functions/gmp-sqrt.xml Sun Feb 8 03:46:23 2004
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-sqrt">
<refnamediv>
<refname>gmp_sqrt</refname>
- <refpurpose>Square root</refpurpose>
+ <refpurpose>Calculate square root</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -13,8 +13,35 @@
<methodparam><type>resource</type><parameter>a</parameter></methodparam>
</methodsynopsis>
<para>
- Calculates square root of <parameter>a</parameter>.
+ Calculates square root of <parameter>a</parameter> and returns the
+ integer portion of the result.
</para>
+ <example>
+ <title><function>gmp_sqrt</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $sqrt1 = gmp_sqrt("9");
+ $sqrt2 = gmp_sqrt("7");
+ $sqrt3 = gmp_sqrt("1524157875019052100");
+
+ echo gmp_strval($sqrt1) . "\n";
+ echo gmp_strval($sqrt2) . "\n";
+ echo gmp_strval($sqrt3) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+3
+2
+1234567890
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-sqrtrem.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-sqrtrem.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-sqrtrem.xml:1.4
phpdoc/en/reference/gmp/functions/gmp-sqrtrem.xml:1.5
--- phpdoc/en/reference/gmp/functions/gmp-sqrtrem.xml:1.4 Tue Jan 13 11:05:06
2004
+++ phpdoc/en/reference/gmp/functions/gmp-sqrtrem.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.gmp-sqrtrem">
<refnamediv>
<refname>gmp_sqrtrem</refname>
@@ -13,9 +13,39 @@
<type>array</type><methodname>gmp_sqrtrem</methodname>
<methodparam><type>resource</type><parameter>a</parameter></methodparam>
</methodsynopsis>
+ <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).
+ </para>
+ <example>
+ <title><function>gmp_sqrtrem</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ list($sqrt1, $sqrt1rem) = gmp_sqrtrem("9");
+ list($sqrt2, $sqrt2rem) = gmp_sqrtrem("7");
+ list($sqrt3, $sqrt3rem) = gmp_sqrtrem("1048576");
- &warn.undocumented.func;
-
+ echo gmp_strval($sqrt1) . ", " . gmp_strval($sqrt1rem) . "\n";
+ echo gmp_strval($sqrt2) . ", " . gmp_strval($sqrt2rem) . "\n";
+ echo gmp_strval($sqrt3) . ", " . gmp_strval($sqrt3rem) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+3, 0
+2, 3
+1024, 0
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-sub.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-sub.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-sub.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-sub.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-sub.xml:1.2 Wed Apr 17 02:38:27 2002
+++ phpdoc/en/reference/gmp/functions/gmp-sub.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-sub">
<refnamediv>
@@ -17,6 +17,25 @@
Subtracts <parameter>b</parameter> from <parameter>a</parameter>
and returns the result.
</para>
+ <example>
+ <title><function>gmp_sub</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+ $sub = gmp_sub("281474976710656", "4294967296"); // 2^48 - 2^32
+ echo gmp_strval($sub) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+281470681743360
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/gmp/functions/gmp-xor.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/gmp/functions/gmp-xor.xml
diff -u phpdoc/en/reference/gmp/functions/gmp-xor.xml:1.2
phpdoc/en/reference/gmp/functions/gmp-xor.xml:1.3
--- phpdoc/en/reference/gmp/functions/gmp-xor.xml:1.2 Wed Apr 17 02:38:27 2002
+++ phpdoc/en/reference/gmp/functions/gmp-xor.xml Sun Feb 8 03:46:23 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-xor">
<refnamediv>
@@ -16,6 +16,28 @@
<para>
Calculates logical exclusive OR (XOR) of two GMP numbers.
</para>
+ <example>
+ <title><function>gmp_xor</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+ $xor1 = gmp_init("1101101110011101", 2);
+ $xor2 = gmp_init("0110011001011001", 2);
+
+ $xor3 = gmp_xor($xor1, $xor2);
+
+ echo gmp_strval($xor3, 2) . "\n";
+?>
+]]>
+ </programlisting>
+ <para>
+ The printout of the above program will be:
+ </para>
+ <screen>
+<![CDATA[
+1011110111000100
+]]>
+ </screen>
+ </example>
</refsect1>
</refentry>