mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fix that rand() bug; double->float; better min() documentation;
possibly something else I don't remember right now :-) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@54456 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
5cc04abe47
commit
d2fc5fd34e
1 changed files with 52 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
|||
<!-- $Revision: 1.47 $ -->
|
||||
<!-- $Revision: 1.48 $ -->
|
||||
<reference id="ref.math">
|
||||
<title>Mathematical Functions</title>
|
||||
<titleabbrev>Math</titleabbrev>
|
||||
|
@ -8,8 +8,9 @@
|
|||
<title>Introduction</title>
|
||||
<para>
|
||||
These math functions will only handle values within the range of
|
||||
the long and double types on your computer. If you need to
|
||||
handle bigger numbers, take a look at the <link
|
||||
the <type>integer</type> and <type>float</type> types on your computer.
|
||||
(this corresponds currently to the C types long resp. double)
|
||||
If you need to handle bigger numbers, take a look at the <link
|
||||
linkend="ref.bc">arbitrary precision math functions</link>.
|
||||
</para>
|
||||
<sect2 id="math.constants">
|
||||
|
@ -140,8 +141,8 @@
|
|||
<para>
|
||||
Returns the absolute value of number. If the argument number is
|
||||
of type <type>float</type>, the return type is also <type>float</type>,
|
||||
otherwise it is <type>int</type> (as <type>float</type> usually has a
|
||||
bigger value range than <type>int</type>).
|
||||
otherwise it is <type>integer</type> (as <type>float</type> usually has a
|
||||
bigger value range than <type>integer</type>).
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -440,8 +441,8 @@ $binary = base_convert ($hexadecimal, 16, 2);
|
|||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>double <function>deg2rad</function></funcdef>
|
||||
<paramdef>double <parameter>number</parameter></paramdef>
|
||||
<funcdef>float <function>deg2rad</function></funcdef>
|
||||
<paramdef>float <parameter>number</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
|
@ -579,7 +580,7 @@ var_dump(hexdec("a0"));
|
|||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>double <function>lcg_value</function></funcdef>
|
||||
<funcdef>float <function>lcg_value</function></funcdef>
|
||||
<paramdef>void</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
@ -652,14 +653,14 @@ var_dump(hexdec("a0"));
|
|||
<para>
|
||||
If the first parameter is an array, <function>max</function>
|
||||
returns the highest value in that array. If the first parameter
|
||||
is an integer, string or double, you need at least two parameters
|
||||
is an integer, string or float, you need at least two parameters
|
||||
and <function>max</function> returns the biggest of these values.
|
||||
You can compare an unlimited number of values.
|
||||
</para>
|
||||
<para>
|
||||
If one or more of the values is a double, all the values will be
|
||||
treated as doubles, and a double is returned. If none of the
|
||||
values is a double, all of them will be treated as integers, and
|
||||
If one or more of the values is a float, all the values will be
|
||||
treated as floats, and a float is returned. If none of the
|
||||
values is a float, all of them will be treated as integers, and
|
||||
an integer is returned.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
@ -674,10 +675,14 @@ var_dump(hexdec("a0"));
|
|||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed <function>min</function></funcdef>
|
||||
<paramdef>mixed <parameter>arg1</parameter></paramdef>
|
||||
<paramdef>mixed <parameter>arg2</parameter></paramdef>
|
||||
<paramdef>mixed <parameter>argn</parameter></paramdef>
|
||||
<funcdef>number <function>min</function></funcdef>
|
||||
<paramdef>number <parameter>arg1</parameter></paramdef>
|
||||
<paramdef>number <parameter>arg2</parameter></paramdef>
|
||||
<paramdef><parameter><optional>...</optional></parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>number <function>min</function></funcdef>
|
||||
<paramdef>array <parameter>numbers</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
|
@ -685,17 +690,20 @@ var_dump(hexdec("a0"));
|
|||
parameter values.
|
||||
</para>
|
||||
<para>
|
||||
If the first parameter is an array, <function>min</function>
|
||||
returns the lowest value in that array. If the first parameter
|
||||
is an integer, string or double, you need at least two parameters
|
||||
In the first variant, you need at least two parameters
|
||||
and <function>min</function> returns the lowest of these values.
|
||||
You can compare an unlimited number of values.
|
||||
</para>
|
||||
<para>
|
||||
If one or more of the values is a double, all the values will be
|
||||
treated as doubles, and a double is returned. If none of the
|
||||
values is a double, all of them will be treated as integers, and
|
||||
an integer is returned.
|
||||
In the second variant, <function>min</function>
|
||||
returns the lowest value in <parameter>numbers</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
If one or more of the values is a <type>float</type>, all the values
|
||||
will be
|
||||
treated as floats, and a float is returned. If none of the
|
||||
values is a float, all of them will be treated as <type>integer</type>s,
|
||||
and an integer is returned.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -708,13 +716,17 @@ var_dump(hexdec("a0"));
|
|||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>mt_rand</function></funcdef>
|
||||
<void/>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>mt_rand</function></funcdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>min</optional></parameter>
|
||||
<parameter>min</parameter>
|
||||
</paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>max</optional></parameter>
|
||||
<parameter>max</parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
@ -782,7 +794,7 @@ var_dump(hexdec("a0"));
|
|||
<informalexample>
|
||||
<programlisting role="php">
|
||||
// seed with microseconds since last "whole" second
|
||||
mt_srand ((double) microtime() * 1000000);
|
||||
mt_srand ((float) microtime() * 1000000);
|
||||
$randval = mt_rand();
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
@ -806,7 +818,7 @@ $randval = mt_rand();
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>mt_getrandmax</function></funcdef>
|
||||
<paramdef>void</paramdef>
|
||||
<void/>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
|
@ -945,7 +957,7 @@ $randval = mt_rand();
|
|||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>double <function>pi</function></funcdef>
|
||||
<funcdef>float <function>pi</function></funcdef>
|
||||
<paramdef>void</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
@ -1027,8 +1039,8 @@ echo pow(-1, 5.5); // error
|
|||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>double <function>rad2deg</function></funcdef>
|
||||
<paramdef>double <parameter>number</parameter></paramdef>
|
||||
<funcdef>float <function>rad2deg</function></funcdef>
|
||||
<paramdef>float <parameter>number</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
|
@ -1049,13 +1061,17 @@ echo pow(-1, 5.5); // error
|
|||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>rand</function></funcdef>
|
||||
<void/>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>rand</function></funcdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>min</optional></parameter>
|
||||
<parameter>min</parameter>
|
||||
</paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>max</optional></parameter>
|
||||
<parameter>max</parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
@ -1098,8 +1114,8 @@ echo pow(-1, 5.5); // error
|
|||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>double <function>round</function></funcdef>
|
||||
<paramdef>double <parameter>val</parameter></paramdef>
|
||||
<funcdef>float <function>round</function></funcdef>
|
||||
<paramdef>float <parameter>val</parameter></paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>precision</optional></parameter>
|
||||
</paramdef>
|
||||
|
@ -1192,7 +1208,7 @@ $foo = round (1.95583, 2); // $foo == 1.96
|
|||
<informalexample>
|
||||
<programlisting role="php">
|
||||
// seed with microseconds since last "whole" second
|
||||
srand ((double) microtime() * 1000000);
|
||||
srand ((float) microtime() * 1000000);
|
||||
$randval = rand();
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
@ -1245,5 +1261,5 @@ sgml-exposed-tags:nil
|
|||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim: ts=4 sw=4 et syntax=sgml
|
||||
vim: ts=1 sw=1 et syntax=sgml
|
||||
-->
|
||||
|
|
Loading…
Reference in a new issue