mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@9864 c90b9560-bf6c-de11-be94-00142212c4b1
911 lines
26 KiB
Text
911 lines
26 KiB
Text
|
|
<reference id="ref.math">
|
|
<title>Mathematical functions</title>
|
|
<titleabbrev>Math.</titleabbrev>
|
|
|
|
<partintro>
|
|
<sect1>
|
|
<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
|
|
linkend="ref.bc">arbitrary precision math functions</link>.
|
|
</para>
|
|
<sect2>
|
|
<title>Math constants</title>
|
|
<para>
|
|
The following values are defined as constants in PHP by the math
|
|
extension:
|
|
<table>
|
|
<title>Math constants</title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>Constant</entry>
|
|
<entry>Value</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>M_PI</entry>
|
|
<entry>3.14159265358979323846</entry>
|
|
<entry>The value of ¶ (pi)</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
</partintro>
|
|
|
|
<refentry id="function.abs">
|
|
<refnamediv>
|
|
<refname>Abs</refname>
|
|
<refpurpose>absolute value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>mixed <function>abs</function></funcdef>
|
|
<paramdef>mixed <parameter>number</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the absolute value of number. If the argument number is
|
|
float, return type is also float, otherwise it is int.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.acos">
|
|
<refnamediv>
|
|
<refname>Acos</refname>
|
|
<refpurpose>arc cosine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>acos</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the arc cosine of arg in radians.
|
|
|
|
<para>
|
|
See also <function>asin</function> and <function>atan</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.asin">
|
|
<refnamediv>
|
|
<refname>Asin</refname>
|
|
<refpurpose>arc sine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>asin</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the arc sine of arg in radians.
|
|
|
|
<para>
|
|
See also <function>acos</function> and <function>atan</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.atan">
|
|
<refnamediv>
|
|
<refname>Atan</refname>
|
|
<refpurpose>arc tangent</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>atan</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the arc tangent of arg in radians.
|
|
|
|
<para>
|
|
See also <function>acos</function> and <function>atan</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.atan2">
|
|
<refnamediv>
|
|
<refname>Atan2</refname>
|
|
<refpurpose>arc tangent of two variables</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>atan2</function></funcdef>
|
|
<paramdef>float <parameter>y</parameter></paramdef>
|
|
<paramdef>float <parameter>x</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
This function calculates the arc tangent of the two variables x and y. It is similar to calculating the
|
|
arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result.
|
|
<simpara>
|
|
The function returns the result in radians, which is between -PI and PI (inclusive).
|
|
<para>
|
|
See also <function>acos</function> and <function>atan</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.base-convert">
|
|
<refnamediv>
|
|
<refname>base_convert</refname>
|
|
<refpurpose>convert a number between arbitrary bases</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>strin <function>base_convert</function></funcdef>
|
|
<paramdef>string <parameter>number</parameter></paramdef>
|
|
<paramdef>int <parameter>frombase</parameter></paramdef>
|
|
<paramdef>int <parameter>tobase</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string containing <parameter>number</parameter>
|
|
represented in base <parameter>tobase</parameter>. The base in
|
|
which <parameter>number</parameter> is given is specified in
|
|
<parameter>frombase</parameter>. Both
|
|
<parameter>frombase</parameter> and <parameter>tobase</parameter>
|
|
have to be between 2 and 36, inclusive. Digits in numbers with a
|
|
base higher than 10 will be represented with the letters a-z,
|
|
with a meaning 10, b meaning 11 and z meaning 36.
|
|
<example>
|
|
<title>base_convert()</title>
|
|
<programlisting role=php>
|
|
$binary = base_convert($hexadecimal, 16, 2);
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.bindec">
|
|
<refnamediv>
|
|
<refname>BinDec</refname>
|
|
<refpurpose>binary to decimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>bindec</function></funcdef>
|
|
<paramdef>string <parameter>binary_string</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the decimal equivalent of the binary number represented by
|
|
the binary_string argument.
|
|
|
|
<para>
|
|
OctDec converts a binary number to a decimal number. The largest
|
|
number that can be converted is 31 bits of 1's or 2147483647 in
|
|
decimal.
|
|
|
|
<para>
|
|
See also the <function>decbin</function>
|
|
function.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.ceil">
|
|
<refnamediv>
|
|
<refname>Ceil</refname>
|
|
<refpurpose>round fractions up</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>ceil</function></funcdef>
|
|
<paramdef>float <parameter>number</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
Returns the next highest integer value from
|
|
<parameter>number</parameter>. Using <function>ceil</function>
|
|
on integers is absolutely a waste of time.
|
|
|
|
<simpara>
|
|
NOTE: PHP/FI 2's <function>ceil</function> returned a
|
|
float. Use: <literal>$new = (double)ceil($number);</literal> to
|
|
get the old behaviour.
|
|
|
|
<simpara>
|
|
See also <function>floor</function> and <function>round</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.cos">
|
|
<refnamediv>
|
|
<refname>Cos</refname>
|
|
<refpurpose>cosine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>cos</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the cosine of arg in radians.
|
|
|
|
<para>
|
|
See also <function>sin</function> and <function>tan</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.decbin">
|
|
<refnamediv>
|
|
<refname>DecBin</refname>
|
|
<refpurpose>decimal to binary</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>string <function>decbin</function></funcdef>
|
|
<paramdef>int <parameter>number</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string containing a binary representation of the given
|
|
number argument. The largest number that can be converted is
|
|
2147483647 in decimal resulting to a string of 31 1's.
|
|
|
|
<para>
|
|
See also the <function>bindec</function>
|
|
function.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.dechex">
|
|
<refnamediv>
|
|
<refname>DecHex</refname>
|
|
<refpurpose>decimal to hexadecimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>string <function>dechex</function></funcdef>
|
|
<paramdef>int <parameter>number</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string containing a hexadecimal representation of the
|
|
given number argument. The largest number that can
|
|
be converted is 2147483647 in decimal resulting to "7fffffff".
|
|
|
|
<para>
|
|
See also the <function>hexdec</function>
|
|
function.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.decoct">
|
|
<refnamediv>
|
|
<refname>DecOct</refname>
|
|
<refpurpose>decimal to octal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>string <function>decoct</function></funcdef>
|
|
<paramdef>int <parameter>number</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns a string containing an octal representation of the given
|
|
number argument. The largest number that can be converted is
|
|
2147483647 in decimal resulting to "17777777777". See also <function>octdec</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.exp">
|
|
<refnamediv>
|
|
<refname>Exp</refname>
|
|
<refpurpose>e to the power of...</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>exp</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns e raised to the power of <parameter>arg</parameter>.
|
|
|
|
<para>
|
|
See also <function>pow</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.floor">
|
|
<refnamediv>
|
|
<refname>Floor</refname>
|
|
<refpurpose>round fractions down</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>floor</function></funcdef>
|
|
<paramdef>float <parameter>number</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<simpara>
|
|
Returns the next lowest integer value from
|
|
<parameter>number</parameter>. Using <function>floor</function>
|
|
on integers is absolutely a waste of time.
|
|
|
|
<simpara>
|
|
NOTE: PHP/FI 2's <function>floor</function> returned a
|
|
float. Use: <literal>$new = (double)floor($number);</literal> to
|
|
get the old behaviour.
|
|
|
|
<simpara>
|
|
See also <function>ceil</function> and <function>round</function>.
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.getrandmax">
|
|
<refnamediv>
|
|
<refname>getrandmax</refname>
|
|
<refpurpose>show largest possible random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>getrandmax</function></funcdef>
|
|
<paramdef>void </paramdef>
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
Returns the maximum value that can be returned by a call to
|
|
<function>rand</function>.
|
|
|
|
<simpara>
|
|
See also <function>rand</function>,
|
|
<function>srand</function>
|
|
<function>mt_rand</function>,
|
|
<function>mt_srand</function> and
|
|
<function>mt_getrandmax</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.hexdec">
|
|
<refnamediv>
|
|
<refname>HexDec</refname>
|
|
<refpurpose>hexadecimal to decimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>hexdec</function></funcdef>
|
|
<paramdef>string <parameter>hex_string</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the decimal equivalent of the hexadecimal number
|
|
represented by the hex_string argument. HexDec converts a
|
|
hexadecimal string to a decimal number. The largest number that
|
|
can be converted is 7fffffff or 2147483647 in decimal.
|
|
|
|
<para>
|
|
See also the <function>dechex</function>
|
|
function.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.log">
|
|
<refnamediv>
|
|
<refname>Log</refname>
|
|
<refpurpose>natural logarithm</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>log</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the natural logarithm of arg.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.log10">
|
|
<refnamediv>
|
|
<refname>Log10</refname>
|
|
<refpurpose>base-10 logarithm</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>log10</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the base-10 logarithm of arg.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.max">
|
|
<refnamediv>
|
|
<refname>max</refname>
|
|
<refpurpose>find highest value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>mixed <function>max</function></funcdef>
|
|
<paramdef>mixed <parameter>arg1</parameter></paramdef>
|
|
<paramdef>mixed <parameter>arg2</parameter></paramdef>
|
|
<paramdef>mixed <parameter>argn</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>max</function> returns the numerically highest of the
|
|
parameter values.
|
|
|
|
<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
|
|
and <function>max</function> returns the biggest of these values.
|
|
You can compare an unlimited number of values.
|
|
|
|
<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.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.min">
|
|
<refnamediv>
|
|
<refname>min</refname>
|
|
<refpurpose>find lowest value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>mixed <function>min</function></funcdef>
|
|
<paramdef>mixed <parameter>arg1</parameter></paramdef>
|
|
<paramdef>mixed <parameter>arg2</parameter></paramdef>
|
|
<paramdef>mixed <parameter>argn</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>min</function> returns the numerically lowest of the
|
|
parameter values.
|
|
<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
|
|
and <function>min</function> returns the lowest of these values.
|
|
You can compare an unlimited number of values.
|
|
<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.
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.mt-rand">
|
|
<refnamediv>
|
|
<refname>mt_rand</refname>
|
|
<refpurpose>generate a better random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>mt_rand</function></funcdef>
|
|
<paramdef><parameter><optional>int min</optional></parameter></paramdef>
|
|
<paramdef><parameter><optional>int max</optional></parameter></paramdef>
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
Many random number generators of older libcs have dubious or
|
|
unknown characteristics and are slow. By default, PHP uses the
|
|
libc random number generator with the <function>rand</function>
|
|
function. <function>mt_rand</function> function is a drop-in
|
|
replacement for this. It uses a random number generator with
|
|
known characteristics, the Mersenne Twister, which will produce
|
|
random numbers that should be suitable for cryptographic purposes
|
|
and is four times faster than what the average libc provides. The
|
|
Homepage of the Mersenne Twister can be found at <ulink
|
|
url="http://www.math.keio.ac.jp/~matumoto/emt.html">http://www.math.keio.ac.jp/~matumoto/emt.html</ulink>,
|
|
and an optimized version of the MT source is available from
|
|
<ulink
|
|
url="http://www.scp.syr.edu/~marc/hawk/twister.html">http://www.scp.syr.edu/~marc/hawk/twister.html</ulink>.
|
|
|
|
<simpara>
|
|
If called without the optional min,max arguments
|
|
<function>mt_rand</function> returns a pseudo-random value
|
|
between 0 and RAND_MAX. If you want a random number between 5
|
|
and 15 (inclusive), for example, use mt_rand(5,15).
|
|
<simpara>
|
|
Remember to seed the random number generator before use with
|
|
<function>mt_srand</function>.
|
|
<simpara>
|
|
See also <function>mt_srand</function>,
|
|
<function>mt_getrandmax</function>,
|
|
<function>srand</function>,
|
|
<function>rand</function> and
|
|
<function>getrandmax</function>.
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.mt-srand">
|
|
<refnamediv>
|
|
<refname>mt_srand</refname>
|
|
<refpurpose>seed the better random number generator</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>void <function>mt_srand</function></funcdef>
|
|
<paramdef>int <parameter>seed</parameter></paramdef>
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
Seeds the random number generator with
|
|
<parameter>seed</parameter>.
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
// seed with microseconds since last "whole" second
|
|
mt_srand((double)microtime()*1000000);
|
|
$randval = mt_rand();
|
|
</programlisting>
|
|
</informalexample>
|
|
|
|
<simpara>
|
|
See also <function>mt_rand</function>,
|
|
<function>mt_getrandmax</function>,
|
|
<function>srand</function>,
|
|
<function>rand</function> and
|
|
<function>getrandmax</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.mt-getrandmax">
|
|
<refnamediv>
|
|
<refname>mt_getrandmax</refname>
|
|
<refpurpose>show largest possible random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>mt_getrandmax</function></funcdef>
|
|
<paramdef>void </paramdef>
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
Returns the maximum value that can be returned by a call to
|
|
<function>mt_rand</function>.
|
|
|
|
<simpara>
|
|
See also <function>mt_rand</function>,
|
|
<function>mt_srand</function>
|
|
<function>rand</function>,
|
|
<function>srand</function> and
|
|
<function>getrandmax</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.number-format">
|
|
<refnamediv>
|
|
<refname>number_format</refname>
|
|
<refpurpose>format a number with grouped thousands</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>string <function>number_format</function></funcdef>
|
|
<paramdef>float <parameter>number</parameter></paramdef>
|
|
<paramdef>int <parameter>decimals</parameter></paramdef>
|
|
<paramdef>string <parameter>dec_point</parameter></paramdef>
|
|
<paramdef>string <parameter>thousands_sep</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
<function>number_format</function> returns a formatted version of
|
|
<parameter>number</parameter>. This function accepts either one,
|
|
two or four parameters (not three):
|
|
</para>
|
|
<para>If only one parameter is given,
|
|
<parameter>number</parameter> will be formatted without decimals,
|
|
but with a comma (",") between every group of thousands.
|
|
</para>
|
|
<para>
|
|
If two parameters are given, <parameter>number</parameter> will
|
|
be formatted with <parameter>decimals</parameter> decimals with a
|
|
dot (".") in front, and a comma (",") between every group of
|
|
thousands.
|
|
</para>
|
|
<para>
|
|
If all four parameters are given, <parameter>number</parameter>
|
|
will be formatted with <parameter>decimals</parameter> decimals,
|
|
<parameter>dec_point</parameter> instead of a dot (".") before
|
|
the decimals and <parameter>thousands_sep</parameter> instead of
|
|
a comma (",") between every group of thousands.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.octdec">
|
|
<refnamediv>
|
|
<refname>OctDec</refname>
|
|
<refpurpose>octal to decimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>octdec</function></funcdef>
|
|
<paramdef>string <parameter>octal_string</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the decimal equivalent of the octal number
|
|
represented by the octal_string argument.
|
|
OctDec converts an octal string to a decimal number. The largest
|
|
number that can be converted is 17777777777 or 2147483647 in
|
|
decimal.
|
|
|
|
<para>
|
|
See also <function>decoct</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.pi">
|
|
<refnamediv>
|
|
<refname>pi</refname>
|
|
<refpurpose>get value of pi</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>double <function>pi</function></funcdef>
|
|
<paramdef>void </paramdef>
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
Returns an approximation of pi.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.pow">
|
|
<refnamediv>
|
|
<refname>pow</refname>
|
|
<refpurpose>exponential expression</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>pow</function></funcdef>
|
|
<paramdef>float <parameter>base</parameter></paramdef>
|
|
<paramdef>float <parameter>exp</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns base raised to the power of exp.
|
|
|
|
<para> See also <function>exp</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.rand">
|
|
<refnamediv>
|
|
<refname>rand</refname>
|
|
<refpurpose>generate a random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>int <function>rand</function></funcdef>
|
|
<paramdef><parameter><optional>int min</optional></parameter></paramdef>
|
|
<paramdef><parameter><optional>int max</optional></parameter></paramdef>
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
If called without the optional min,max arguments rand() returns a
|
|
pseudo-random value between 0 and RAND_MAX. If you want a random
|
|
number between 5 and 15 (inclusive), for example, use rand(5,15).
|
|
|
|
<simpara>
|
|
Remember to seed the random number generator before use with
|
|
<function>srand</function>.
|
|
<simpara>
|
|
See also <function>srand</function>,
|
|
<function>getrandmax</function>,
|
|
<function>mt_rand</function>,
|
|
<function>mt_srand</function> and
|
|
<function>mt_getrandmax</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.round">
|
|
<refnamediv>
|
|
<refname>round</refname>
|
|
<refpurpose>Rounds a float.</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>double <function>round</function></funcdef>
|
|
<paramdef>double <parameter>val</parameter></paramdef>
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
Returns the rounded value of <parameter>val</parameter>.
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
$foo = round( 3.4 ); // $foo == 3.0
|
|
$foo = round( 3.5 ); // $foo == 4.0
|
|
$foo = round( 3.6 ); // $foo == 4.0
|
|
</programlisting>
|
|
</informalexample>
|
|
|
|
<simpara>
|
|
See also <function>ceil</function> and <function>floor</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.sin">
|
|
<refnamediv>
|
|
<refname>Sin</refname>
|
|
<refpurpose>sine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>sin</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the sine of arg in radians.
|
|
|
|
<para>
|
|
See also <function>cos</function> and <function>tan</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.sqrt">
|
|
<refnamediv>
|
|
<refname>Sqrt</refname>
|
|
<refpurpose>square root</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>sqrt</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
Returns the square root of arg.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.srand">
|
|
<refnamediv>
|
|
<refname>srand</refname>
|
|
<refpurpose>seed the random number generator</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>void <function>srand</function></funcdef>
|
|
<paramdef>int <parameter>seed</parameter></paramdef>
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
Seeds the random number generator with
|
|
<parameter>seed</parameter>.
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
// seed with microseconds since last "whole" second
|
|
srand((double)microtime()*1000000);
|
|
$randval = rand();
|
|
</programlisting>
|
|
</informalexample>
|
|
|
|
<simpara>
|
|
See also <function>rand</function>,
|
|
<function>getrandmax</function>,
|
|
<function>mt_rand</function>,
|
|
<function>mt_srand</function> and
|
|
<function>mt_getrandmax</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.tan">
|
|
<refnamediv>
|
|
<refname>Tan</refname>
|
|
<refpurpose>tangent</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<funcsynopsis>
|
|
<funcdef>float <function>tan</function></funcdef>
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
</funcsynopsis>
|
|
<para>
|
|
Returns the tangent of arg in radians.
|
|
|
|
<para>
|
|
See also <function>sin</function> and <function>cos</function>.
|
|
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
</reference>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
-->
|