mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Improved GMP random functions added in 5.6.2
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@335072 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
7895293e60
commit
e94c8d47d0
3 changed files with 202 additions and 0 deletions
96
reference/gmp/functions/gmp_random_bits.xml
Normal file
96
reference/gmp/functions/gmp_random_bits.xml
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.gmp-random-bits">
|
||||
<refnamediv>
|
||||
<refname>gmp_random_bits</refname>
|
||||
<refpurpose>Random number</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>GMP</type><methodname>gmp_random_bits</methodname>
|
||||
<methodparam><type>integer</type><parameter>bits</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Generate a random number. The number will be between
|
||||
0 and (2 ** <parameter>bits</parameter>) - 1.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>bits</parameter> must greater than 0, and the maximum value is restricted by available memory.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>bits</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The number of bits.
|
||||
</para>
|
||||
&gmp.parameter;
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
A random GMP number.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>gmp_random_bits</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$rand1 = gmp_random_bits(3); // random number from 0 to 7
|
||||
$rand2 = gmp_random_bits(5); // random number from 0 to 31
|
||||
|
||||
echo gmp_strval($rand1) . "\n";
|
||||
echo gmp_strval($rand2) . "\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
3
|
||||
15
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- 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:"~/.phpdoc/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
|
||||
-->
|
104
reference/gmp/functions/gmp_random_range.xml
Normal file
104
reference/gmp/functions/gmp_random_range.xml
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.gmp-random-range">
|
||||
<refnamediv>
|
||||
<refname>gmp_random_range</refname>
|
||||
<refpurpose>Random number</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>GMP</type><methodname>gmp_random_range</methodname>
|
||||
<methodparam><type>GMP</type><parameter>min</parameter></methodparam>
|
||||
<methodparam><type>GMP</type><parameter>max</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Generate a random number. The number will be between
|
||||
<parameter>min</parameter> and <parameter>max</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>min</parameter> and <parameter>max</parameter> can both be negative but <parameter>min</parameter> must always be less than <parameter>max</parameter>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>min</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A GMP number representing the lower bound for the random number
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>max</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A GMP number representing the upper bound for the random number
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
A random GMP number.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>gmp_random_range</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$rand1 = gmp_random_range(0, 100); // random number between 0 and 100
|
||||
$rand2 = gmp_random_range(-100, -10); // random number between -100 and -10
|
||||
|
||||
echo gmp_strval($rand1) . "\n";
|
||||
echo gmp_strval($rand2) . "\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
42
|
||||
-67
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- 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:"~/.phpdoc/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
|
||||
-->
|
|
@ -38,6 +38,8 @@
|
|||
<function name='gmp_powm' from='PHP 4 >= 4.0.4, PHP 5'/>
|
||||
<function name='gmp_prob_prime' from='PHP 4 >= 4.0.4, PHP 5'/>
|
||||
<function name='gmp_random' from='PHP 4 >= 4.0.4, PHP 5'/>
|
||||
<function name='gmp_random_bits' from='PHP 5 >= 5.6.2'/>
|
||||
<function name='gmp_random_range' from='PHP 5 >= 5.6.2'/>
|
||||
<function name='gmp_root' from='PHP 5 >= 5.6.0'/>
|
||||
<function name='gmp_rootrem' from='PHP 5 >= 5.6.0'/>
|
||||
<function name='gmp_scan0' from='PHP 4 >= 4.0.4, PHP 5'/>
|
||||
|
|
Loading…
Reference in a new issue