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

removing the others git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78562 c90b9560-bf6c-de11-be94-00142212c4b1
1521 lines
46 KiB
XML
1521 lines
46 KiB
XML
<!-- D O N O T E D I T T H I S F I L E ! ! !
|
|
|
|
it is still here for historical reasons only
|
|
(as translators may need to check old revision diffs)
|
|
|
|
if you want to change things documented in this file
|
|
you should now edit the files found under en/reference
|
|
instead -->
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.79 $ -->
|
|
<reference id="ref.math">
|
|
<title>Mathematical Functions</title>
|
|
<titleabbrev>Math</titleabbrev>
|
|
|
|
<partintro>
|
|
<sect1 id="math.intro">
|
|
<title>Introduction</title>
|
|
<para>
|
|
These math functions will only handle values within the range of
|
|
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">
|
|
<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>Pi</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_E</entry>
|
|
<entry>2.7182818284590452354</entry>
|
|
<entry>e</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_LOG2E</entry>
|
|
<entry>1.4426950408889634074</entry>
|
|
<entry>log_2 e</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_LOG10E</entry>
|
|
<entry>0.43429448190325182765</entry>
|
|
<entry>log_10 e</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_LN2</entry>
|
|
<entry>0.69314718055994530942</entry>
|
|
<entry>log_e 2</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_LN10</entry>
|
|
<entry>2.30258509299404568402</entry>
|
|
<entry>log_e 10</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_PI_2</entry>
|
|
<entry>1.57079632679489661923</entry>
|
|
<entry>pi/2</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_PI_4</entry>
|
|
<entry>0.78539816339744830962</entry>
|
|
<entry>pi/4</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_1_PI</entry>
|
|
<entry>0.31830988618379067154</entry>
|
|
<entry>1/pi</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_2_PI</entry>
|
|
<entry>0.63661977236758134308</entry>
|
|
<entry>2/pi</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_SQRTPI</entry>
|
|
<entry>1.77245385090551602729</entry>
|
|
<entry>sqrt(pi) [4.0.2]</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_2_SQRTPI</entry>
|
|
<entry>1.12837916709551257390</entry>
|
|
<entry>2/sqrt(pi)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_SQRT2</entry>
|
|
<entry>1.41421356237309504880</entry>
|
|
<entry>sqrt(2)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_SQRT3</entry>
|
|
<entry>1.73205080756887729352</entry>
|
|
<entry>sqrt(3) [4.0.2]</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_SQRT1_2</entry>
|
|
<entry>0.70710678118654752440</entry>
|
|
<entry>1/sqrt(2)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_LNPI</entry>
|
|
<entry>1.14472988584940017414</entry>
|
|
<entry>log_e(pi) [4.0.2]</entry>
|
|
</row>
|
|
<row>
|
|
<entry>M_EULER</entry>
|
|
<entry>0.57721566490153286061</entry>
|
|
<entry>Euler constant [4.0.2]</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
Only M_PI is available in PHP versions up to and including PHP 4.0.0.
|
|
All other constants are available starting with PHP 4.0.0. Constants
|
|
labeled [4.0.2] were added in PHP 4.0.2.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
</partintro>
|
|
|
|
<refentry id="function.abs">
|
|
<refnamediv>
|
|
<refname>abs</refname>
|
|
<refpurpose>Absolute value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>abs</methodname>
|
|
<methodparam><type>mixed</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>integer</type> (as <type>float</type> usually has a
|
|
bigger value range than <type>integer</type>).
|
|
</para>
|
|
<example>
|
|
<title><function>abs</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
$abs = abs(-4.2); // $abs = 4.2; (double/float)
|
|
$abs2 = abs(5); // $abs2 = 5; (integer)
|
|
$abs3 = abs(-5); // $abs3 = 5; (integer)
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.acos">
|
|
<refnamediv>
|
|
<refname>acos</refname>
|
|
<refpurpose>Arc cosine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>acos</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the arc cosine of <parameter>arg</parameter> in radians.
|
|
</para>
|
|
<para>
|
|
See also <function>acosh</function>, <function>asin</function>
|
|
and <function>atan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.acosh">
|
|
<refnamediv>
|
|
<refname>acosh</refname>
|
|
<refpurpose>Inverse hyperbolic cosine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>acosh</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the inverse hyperbolic cosine of
|
|
<parameter>arg</parameter>, i.e. the value whose
|
|
hyperbolic cosine is <parameter>arg</parameter>.
|
|
</para>
|
|
¬e.no-windows;
|
|
<para>
|
|
See also <function>acos</function>, <function>asin</function>
|
|
and <function>atan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.asin">
|
|
<refnamediv>
|
|
<refname>asin</refname>
|
|
<refpurpose>Arc sine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>asin</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the arc sine of arg in radians.
|
|
</para>
|
|
<para>
|
|
See also <function>asinh</function>, <function>acos</function>
|
|
and <function>atan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.asinh">
|
|
<refnamediv>
|
|
<refname>asinh</refname>
|
|
<refpurpose>Inverse hyperbolic sine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>asinh</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the inverse hyperbolic sine of
|
|
<parameter>arg</parameter>, i.e. the value whose
|
|
hyperbolic sine is <parameter>arg</parameter>.
|
|
</para>
|
|
¬e.no-windows;
|
|
<para>
|
|
See also <function>asin</function>, <function>acos</function>
|
|
and <function>atan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.atan">
|
|
<refnamediv>
|
|
<refname>atan</refname>
|
|
<refpurpose>Arc tangent</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>atan</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the arc tangent of arg in radians.
|
|
</para>
|
|
<para>
|
|
See also <function>atanh</function>, <function>asin</function>
|
|
and <function>acos</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.atanh">
|
|
<refnamediv>
|
|
<refname>atanh</refname>
|
|
<refpurpose>Inverse hyperbolic tangent</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>atanh</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the inverse hyperbolic tangent of
|
|
<parameter>arg</parameter>, i.e. the value whose
|
|
hyperbolic tangent is <parameter>arg</parameter>.
|
|
</para>
|
|
¬e.no-windows;
|
|
<para>
|
|
See also <function>atan</function>, <function>asin</function>
|
|
and <function>acos</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.atan2">
|
|
<refnamediv>
|
|
<refname>atan2</refname>
|
|
<refpurpose>arc tangent of two variables</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>atan2</methodname>
|
|
<methodparam><type>float</type><parameter>y</parameter></methodparam>
|
|
<methodparam><type>float</type><parameter>x</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
This function calculates the arc tangent of the two variables
|
|
<parameter>x</parameter> and <parameter>y</parameter>. It is
|
|
similar to calculating the arc tangent of
|
|
<parameter>y</parameter> / <parameter>x</parameter>, except that
|
|
the signs of both arguments are used to determine the quadrant of
|
|
the result.
|
|
</simpara>
|
|
<simpara>
|
|
The function returns the result in radians, which is between -PI
|
|
and PI (inclusive).
|
|
</simpara>
|
|
<para>
|
|
See also <function>acos</function> and <function>atan</function>.
|
|
</para>
|
|
</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>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>base_convert</methodname>
|
|
<methodparam><type>string</type><parameter>number</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>frombase</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>tobase</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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 35.
|
|
<example>
|
|
<title><function>base_convert</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
$binary = base_convert ($hexadecimal, 16, 2);
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
|
|
<refentry id="function.bindec">
|
|
<refnamediv>
|
|
<refname>bindec</refname>
|
|
<refpurpose>Binary to decimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>bindec</methodname>
|
|
<methodparam><type>string</type><parameter>binary_string</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the decimal equivalent of the binary number represented by
|
|
the binary_string argument.
|
|
</para>
|
|
<para>
|
|
<function>bindec</function> converts a binary number to an
|
|
<type>integer</type>. The largest number that can be converted is
|
|
31 bits of 1's or 2147483647 in decimal.
|
|
</para>
|
|
<para>
|
|
See also the <function>decbin</function>
|
|
function.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.ceil">
|
|
<refnamediv>
|
|
<refname>ceil</refname>
|
|
<refpurpose>Round fractions up</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>ceil</methodname>
|
|
<methodparam><type>float</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Returns the next highest integer value by rounding up
|
|
<parameter>value</parameter> if necessary.
|
|
The return value of <function>ceil</function> is still of type
|
|
<type>float</type> as the value range of <type>float</type> is
|
|
usually bigger than that of <type>int</type>.
|
|
</simpara>
|
|
<example>
|
|
<title><function>ceil</function> examples</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
$five = ceil(4.3); // $five = 5.0;
|
|
$ten = ceil(9.999); // $ten = 10.0;
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<simpara>
|
|
See also <function>floor</function> and
|
|
<function>round</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.cos">
|
|
<refnamediv>
|
|
<refname>cos</refname>
|
|
<refpurpose>Cosine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>cos</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the cosine of arg in radians.
|
|
</para>
|
|
<para>
|
|
See also <function>sin</function> and <function>tan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.cosh">
|
|
<refnamediv>
|
|
<refname>cosh</refname>
|
|
<refpurpose>Hyperbolic cosine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>cosh</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the hyperbolic cosine of <parameter>arg</parameter>,
|
|
defined as <literal>(exp(arg) + exp(-arg))/2</literal>.
|
|
</para>
|
|
<para>
|
|
See also <function>cos</function>, <function>acosh</function>,
|
|
<function>sin</function> and <function>tan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.decbin">
|
|
<refnamediv>
|
|
<refname>decbin</refname>
|
|
<refpurpose>Decimal to binary</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>decbin</methodname>
|
|
<methodparam><type>int</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns a string containing a binary representation of the given
|
|
number argument. The largest number that can be converted is
|
|
4294967295 in decimal resulting to a string of 32 1's.
|
|
</para>
|
|
<para>
|
|
See also the <function>bindec</function> function.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.dechex">
|
|
<refnamediv>
|
|
<refname>dechex</refname>
|
|
<refpurpose>Decimal to hexadecimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>dechex</methodname>
|
|
<methodparam><type>int</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>
|
|
<para>
|
|
See also <function>hexdec</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.decoct">
|
|
<refnamediv>
|
|
<refname>decoct</refname>
|
|
<refpurpose>Decimal to octal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>decoct</methodname>
|
|
<methodparam><type>int</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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".
|
|
</para>
|
|
<para>
|
|
See also <function>octdec</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.deg2rad">
|
|
<refnamediv>
|
|
<refname>deg2rad</refname>
|
|
<refpurpose>
|
|
Converts the number in degrees to the radian equivalent
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>deg2rad</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
This function converts <parameter>number</parameter> from degrees
|
|
to the radian equivalent.
|
|
</para>
|
|
<para>
|
|
See also <function>rad2deg</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.exp">
|
|
<refnamediv>
|
|
<refname>exp</refname>
|
|
<refpurpose>e to the power of ...</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>exp</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns e raised to the power of <parameter>arg</parameter>.
|
|
</para>
|
|
<para>
|
|
See also <function>pow</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id='function.expm1'>
|
|
<refnamediv>
|
|
<refname>expm1</refname>
|
|
<refpurpose>
|
|
Returns exp(number) - 1, computed in a way that accurate even
|
|
when the value of number is close to zero
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>expm1</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
&warn.experimental.func;
|
|
<para>
|
|
&warn.undocumented.func;
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.floor">
|
|
<refnamediv>
|
|
<refname>floor</refname>
|
|
<refpurpose>Round fractions down</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>floor</methodname>
|
|
<methodparam><type>float</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Returns the next lowest integer value by rounding down
|
|
<parameter>value</parameter> if necessary.
|
|
The return value of <function>floor</function> is still of type
|
|
<type>float</type> because the value range of <type>float</type> is
|
|
usually bigger than that of <type>int</type>.
|
|
</simpara>
|
|
<example>
|
|
<title><function>floor</function> examples</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
$four = floor(4.3); // $four = 4.0;
|
|
$nine = floor(9.999); // $nine = 9.0;
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<simpara>
|
|
See also <function>ceil</function> and
|
|
<function>round</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.getrandmax">
|
|
<refnamediv>
|
|
<refname>getrandmax</refname>
|
|
<refpurpose>Show largest possible random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>getrandmax</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Returns the maximum value that can be returned by a call to
|
|
<function>rand</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also <function>rand</function>, <function>srand</function>,
|
|
<function>mt_rand</function>, <function>mt_srand</function>, and
|
|
<function>mt_getrandmax</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.hexdec">
|
|
<refnamediv>
|
|
<refname>hexdec</refname>
|
|
<refpurpose>Hexadecimal to decimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>hexdec</methodname>
|
|
<methodparam><type>string</type><parameter>hex_string</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the decimal equivalent of the hexadecimal number
|
|
represented by the hex_string argument. <function>hexdec</function> converts a
|
|
hexadecimal string to a decimal number. The largest number that
|
|
can be converted is 7fffffff or 2147483647 in decimal.
|
|
</para>
|
|
<para>
|
|
<function>hexdec</function> will replace of any non-hexadecimal
|
|
characters it encounters by <literal>0</literal>. This way, all
|
|
left zeros are ignored, but right zeros will be valued.
|
|
<example>
|
|
<title><function>hexdec</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
var_dump(hexdec("See"));
|
|
var_dump(hexdec("ee"));
|
|
// both prints "int(238)"
|
|
|
|
var_dump(hexdec("that"));
|
|
var_dump(hexdec("a0"));
|
|
// both prints int(160)
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
See also <function>dechex</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id='function.hypot'>
|
|
<refnamediv>
|
|
<refname>hypot</refname>
|
|
<refpurpose>
|
|
Returns sqrt( num1*num1 + num2*num2)
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>hypot</methodname>
|
|
<methodparam><type>float</type><parameter>num1</parameter></methodparam>
|
|
<methodparam><type>float</type><parameter>num2</parameter></methodparam>
|
|
</methodsynopsis>
|
|
&warn.experimental.func;
|
|
<para>
|
|
&warn.undocumented.func;
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id='function.is-finite'>
|
|
<refnamediv>
|
|
<refname>is_finite</refname>
|
|
<refpurpose>
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>is_finite</methodname>
|
|
<methodparam><type>float</type><parameter>val</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns &true; if <parameter>val</parameter> is a legal finite
|
|
number within the allowed range for a PHP float on this platform.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id='function.is-infinite'>
|
|
<refnamediv>
|
|
<refname>is_infinite</refname>
|
|
<refpurpose>
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>is_infinite</methodname>
|
|
<methodparam><type>float</type><parameter>val</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns &true; if <parameter>val</parameter> is infinite (positive or
|
|
negative), like the result of <literal>log(0)</literal> or any value too
|
|
big to fit into a float on this platform.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id='function.is-nan'>
|
|
<refnamediv>
|
|
<refname>is_nan</refname>
|
|
<refpurpose>
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>is_nan</methodname>
|
|
<methodparam><type>float</type><parameter>val</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns &true; if <parameter>val</parameter> is 'not a number',
|
|
like the result of <literal>acos(1.01)</literal>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.lcg-value">
|
|
<refnamediv>
|
|
<refname>lcg_value</refname>
|
|
<refpurpose>Combined linear congruential generator</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>lcg_value</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>lcg_value</function> returns a pseudo random number in
|
|
the range of (0, 1). The function combines two CGs with periods
|
|
of 2^31 - 85 and 2^31 - 249. The period of this function is equal
|
|
to the product of both primes.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.log">
|
|
<refnamediv>
|
|
<refname>log</refname>
|
|
<refpurpose>Natural logarithm</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>log</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the natural logarithm of arg.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.log10">
|
|
<refnamediv>
|
|
<refname>log10</refname>
|
|
<refpurpose>Base-10 logarithm</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>log10</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the base-10 logarithm of <parameter>arg</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id='function.log1p'>
|
|
<refnamediv>
|
|
<refname>log1p</refname>
|
|
<refpurpose>
|
|
Returns log(1 + number), computed in a way that accurate even when the val
|
|
ue of number is close to zero
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>log1p</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
&warn.experimental.func;
|
|
<para>
|
|
&warn.undocumented.func;
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.max">
|
|
<refnamediv>
|
|
<refname>max</refname>
|
|
<refpurpose>Find highest value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>max</methodname>
|
|
<methodparam><type>mixed</type><parameter>arg1</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>arg2</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>argn</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>max</function> returns the numerically highest of the
|
|
parameter values.
|
|
</para>
|
|
<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 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 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>
|
|
</refentry>
|
|
|
|
<refentry id="function.min">
|
|
<refnamediv>
|
|
<refname>min</refname>
|
|
<refpurpose>Find lowest value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>number</type><methodname>min</methodname>
|
|
<methodparam><type>number</type><parameter>arg1</parameter></methodparam>
|
|
<methodparam><type>number</type><parameter>arg2</parameter></methodparam>
|
|
<methodparam choice="opt"><parameter>...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>number</type><methodname>min</methodname>
|
|
<methodparam><type>array</type><parameter>numbers</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>min</function> returns the numerically lowest of the
|
|
parameter values.
|
|
</para>
|
|
<para>
|
|
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>
|
|
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>
|
|
|
|
<refentry id="function.mt-rand">
|
|
<refnamediv>
|
|
<refname>mt_rand</refname>
|
|
<refpurpose>Generate a better random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>mt_rand</methodname>
|
|
<methodparam choice="opt"><type>int</type><parameter>min</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>max</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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 seeding some kinds
|
|
of cryptography (see the home pages for details) and is four
|
|
times faster than what the average libc provides. The Homepage
|
|
of the Mersenne Twister can be found at
|
|
<ulink url="&url.mersenne;">&url.mersenne;</ulink>, and an
|
|
optimized version of the MT source is available from
|
|
<ulink url="&url.mersenne.twister;">&url.mersenne.twister;
|
|
</ulink>.
|
|
</simpara>
|
|
<simpara>
|
|
If called without the optional <parameter>min</parameter>,
|
|
<parameter>max</parameter> arguments <function>mt_rand</function>
|
|
returns a pseudo-random value between 0 and
|
|
<constant>RAND_MAX</constant>. If you want a random number
|
|
between 5 and 15 (inclusive), for example, use <literal>mt_rand
|
|
(5, 15)</literal>.
|
|
</simpara>
|
|
<simpara>
|
|
Remember to seed the random number generator before use with
|
|
<function>mt_srand</function>.
|
|
</simpara>
|
|
<note>
|
|
<para>
|
|
In versions before 3.0.7 the meaning of
|
|
<parameter>max</parameter> was <parameter>range</parameter>. To
|
|
get the same results in these versions the short example should
|
|
be <literal>mt_rand (5, 11)</literal> to get a random number
|
|
between 5 and 15.
|
|
</para>
|
|
</note>
|
|
<simpara>
|
|
See also <function>mt_srand</function>,
|
|
<function>mt_getrandmax</function>, <function>srand</function>,
|
|
<function>rand</function> and <function>getrandmax</function>.
|
|
</simpara>
|
|
</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>
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>mt_srand</methodname>
|
|
<methodparam><type>int</type><parameter>seed</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Seeds the random number generator with
|
|
<parameter>seed</parameter>.
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
// seed with microseconds
|
|
function make_seed() {
|
|
list($usec, $sec) = explode(' ', microtime());
|
|
return (float) $sec + ((float) $usec * 100000);
|
|
}
|
|
mt_srand(make_seed());
|
|
$randval = mt_rand();
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
<simpara>
|
|
See also <function>mt_rand</function>,
|
|
<function>mt_getrandmax</function>, <function>srand</function>,
|
|
<function>rand</function>, and
|
|
<function>getrandmax</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.mt-getrandmax">
|
|
<refnamediv>
|
|
<refname>mt_getrandmax</refname>
|
|
<refpurpose>Show largest possible random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>mt_getrandmax</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Returns the maximum value that can be returned by a call to
|
|
<function>mt_rand</function>.
|
|
</simpara>
|
|
<simpara>
|
|
See also <function>mt_rand</function>,
|
|
<function>mt_srand</function>, <function>rand</function>,
|
|
<function>srand</function>, and
|
|
<function>getrandmax</function>.
|
|
</simpara>
|
|
</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>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>number_format</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>decimals</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>dec_point</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>thousands_sep</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>
|
|
<note>
|
|
<para>
|
|
Only the first character of <parameter>thousands_sep</parameter>
|
|
is used. For example, if you use <literal>foo</literal> as
|
|
<parameter>thousands_sep</parameter> on the number
|
|
<literal>1000</literal>, <function>number_format</function> will
|
|
return <literal>1f000</literal>.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title><function>number_format</function> Example</title>
|
|
<para>
|
|
For instance, French notation usually use two decimals,
|
|
comma (',') as decimal separator, and space (' ') as
|
|
thousand separator. This is achieved with this line :
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$number = 1234.56;
|
|
|
|
// english notation (default)
|
|
$english_format_number = number_format($number);
|
|
// 1,234.56
|
|
|
|
// French notation
|
|
$nombre_format_francais = number_format($number, 2, ',', ' ');
|
|
// 1 234,56
|
|
|
|
|
|
$number = 1234.5678;
|
|
|
|
// english notation without thousands seperator
|
|
$english_format_number = number_format($number, 2, '.', '');
|
|
// 1234.56
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
See also: <function>sprintf</function>,
|
|
<function>printf</function> and <function>sscanf</function>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.octdec">
|
|
<refnamediv>
|
|
<refname>octdec</refname>
|
|
<refpurpose>Octal to decimal</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>octdec</methodname>
|
|
<methodparam><type>string</type><parameter>octal_string</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the decimal equivalent of the octal number
|
|
represented by the <parameter>octal_string</parameter> argument.
|
|
The largest number that can be converted is 17777777777 or 2147483647 in
|
|
decimal.
|
|
</para>
|
|
<para>
|
|
See also <function>decoct</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.pi">
|
|
<refnamediv>
|
|
<refname>pi</refname>
|
|
<refpurpose>Get value of pi</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>pi</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Returns an approximation of pi. The returned <type>float</type>
|
|
has a precision based on the
|
|
<link linkend="ini.precision">precision</link> directive in
|
|
&php.ini;, which defaults to <literal>14</literal>.
|
|
Also, you can use the <constant>M_PI</constant> constant which yields
|
|
identical results to <function>pi</function>.
|
|
</simpara>
|
|
<para>
|
|
<informalexample>
|
|
<programlisting>
|
|
<![CDATA[
|
|
echo pi(); // 3.1415926535898
|
|
echo M_PI; // 3.1415926535898
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.pow">
|
|
<refnamediv>
|
|
<refname>pow</refname>
|
|
<refpurpose>Exponential expression</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>number</type><methodname>pow</methodname>
|
|
<methodparam><type>number</type><parameter>base</parameter></methodparam>
|
|
<methodparam><type>number</type><parameter>exp</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns <parameter>base</parameter> raised to the power of
|
|
<parameter>exp</parameter>. If possible, this function will
|
|
return an <type>integer</type>.
|
|
</para>
|
|
<para>
|
|
If the power cannot be computed, a warning will be issued,
|
|
and <function>pow</function> will return &false;.
|
|
</para>
|
|
<example>
|
|
<title>Some examples of <function>pow</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
var_dump( pow(2,8) ); // int(256)
|
|
echo pow(-1,20); // 1
|
|
echo pow(0, 0); // 1
|
|
|
|
echo pow(-1, 5.5); // error
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<warning>
|
|
<para>
|
|
In PHP 4.0.6 and earlier <function>pow</function> always returned
|
|
a <type>float</type>, and did not issue warnings.
|
|
</para>
|
|
</warning>
|
|
<para>
|
|
See also <function>exp</function> and <function>sqrt</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.rad2deg">
|
|
<refnamediv>
|
|
<refname>rad2deg</refname>
|
|
<refpurpose>
|
|
Converts the radian number to the equivalent number in degrees
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>rad2deg</methodname>
|
|
<methodparam><type>float</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
This function converts <parameter>number</parameter> from radian
|
|
to degrees.
|
|
</para>
|
|
<para>
|
|
See also <function>deg2rad</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.rand">
|
|
<refnamediv>
|
|
<refname>rand</refname>
|
|
<refpurpose>Generate a random value</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>rand</methodname>
|
|
<methodparam choice="opt"><type>int</type><parameter>min</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>max</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
If called without the optional <parameter>min</parameter>,
|
|
<parameter>max</parameter> arguments <function>rand</function>
|
|
returns a pseudo-random value between 0 and
|
|
<constant>RAND_MAX</constant>. If you want a random number
|
|
between 5 and 15 (inclusive), for example, use <literal>rand (5,
|
|
15)</literal>.
|
|
</simpara>
|
|
<simpara>
|
|
Remember to seed the random number generator before use with
|
|
<function>srand</function>.
|
|
</simpara>
|
|
<note>
|
|
<para>
|
|
In versions before 3.0.7 the meaning of
|
|
<parameter>max</parameter> was <parameter>range</parameter>. To
|
|
get the same results in these versions the short example should
|
|
be <literal>rand (5, 11)</literal> to get a random number
|
|
between 5 and 15.
|
|
</para>
|
|
</note>
|
|
<simpara>
|
|
See also <function>srand</function>,
|
|
<function>getrandmax</function>, <function>mt_rand</function>,
|
|
<function>mt_srand</function>, and
|
|
<function>mt_getrandmax</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.round">
|
|
<refnamediv>
|
|
<refname>round</refname>
|
|
<refpurpose>Rounds a float</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>round</methodname>
|
|
<methodparam><type>float</type><parameter>val</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>precision</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the rounded value of <parameter>val</parameter> to
|
|
specified <parameter>precision</parameter>
|
|
(number of digits after the decimal point).
|
|
<parameter>precision</parameter> can also be negative or zero (default).
|
|
</para>
|
|
<para>
|
|
<caution>
|
|
<simpara>
|
|
PHP doesn't handle strings like <literal>"12,300.2"</literal> correctly
|
|
by default. See <link linkend="language.types.string.conversion"
|
|
>converting from strings</link>.
|
|
</simpara>
|
|
</caution>
|
|
</para>
|
|
<para>
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
$foo = round(3.4); // $foo == 3.0
|
|
$foo = round(3.5); // $foo == 4.0
|
|
$foo = round(3.6); // $foo == 4.0
|
|
$foo = round(3.6, 0); // equivalent with above
|
|
|
|
$foo = round(1.95583, 2); // $foo == 1.96
|
|
|
|
$foo = round(1241757, -3); // $foo == 1242000
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
The <parameter>precision</parameter> parameter is only
|
|
available in PHP 4.
|
|
</simpara>
|
|
</note>
|
|
<simpara>
|
|
See also <function>ceil</function> and
|
|
<function>floor</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.sin">
|
|
<refnamediv>
|
|
<refname>sin</refname>
|
|
<refpurpose>Sine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>sin</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the sine of arg in radians.
|
|
</para>
|
|
<para>
|
|
See also <function>cos</function> and <function>tan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.sinh">
|
|
<refnamediv>
|
|
<refname>sinh</refname>
|
|
<refpurpose>Hyperbolic sine</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>sinh</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the hyperbolic sine of <parameter>arg</parameter>,
|
|
defined as <literal>(exp(arg) - exp(-arg))/2</literal>.
|
|
</para>
|
|
<para>
|
|
See also <function>sin</function>, <function>asinh</function>,
|
|
<function>cos</function> and <function>tan</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.sqrt">
|
|
<refnamediv>
|
|
<refname>sqrt</refname>
|
|
<refpurpose>Square root</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>sqrt</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the square root of <parameter>arg</parameter>.
|
|
</para>
|
|
<para>
|
|
See also <function>pow</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.srand">
|
|
<refnamediv>
|
|
<refname>srand</refname>
|
|
<refpurpose>Seed the random number generator</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>srand</methodname>
|
|
<methodparam><type>int</type><parameter>seed</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Seeds the random number generator with
|
|
<parameter>seed</parameter>.
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
// seed with microseconds
|
|
function make_seed() {
|
|
list($usec, $sec) = explode(' ', microtime());
|
|
return (float) $sec + ((float) $usec * 100000);
|
|
}
|
|
srand(make_seed());
|
|
$randval = rand();
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
<simpara>
|
|
See also <function>rand</function>,
|
|
<function>getrandmax</function>, <function>mt_rand</function>,
|
|
<function>mt_srand</function>, and
|
|
<function>mt_getrandmax</function>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.tan">
|
|
<refnamediv>
|
|
<refname>tan</refname>
|
|
<refpurpose>Tangent</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>tan</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the tangent of arg in radians.
|
|
</para>
|
|
<para>
|
|
See also <function>sin</function> and <function>cos</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.tanh">
|
|
<refnamediv>
|
|
<refname>tanh</refname>
|
|
<refpurpose>Hyperbolic tangent</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>float</type><methodname>tanh</methodname>
|
|
<methodparam><type>float</type><parameter>arg</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the hyperbolic tangent of <parameter>arg</parameter>,
|
|
defined as <literal>sinh(arg)/cosh(arg)</literal>.
|
|
</para>
|
|
<para>
|
|
See also <function>tan</function>, <function>atanh</function>,
|
|
<function>sin</function> and <function>cos</function>.
|
|
</para>
|
|
</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
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../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
|
|
-->
|
|
|