1999-06-06 18:51:02 +00:00
|
|
|
<reference id="ref.math">
|
2000-08-18 12:03:50 +00:00
|
|
|
<title>Mathematical Functions</title>
|
1999-06-06 18:51:02 +00:00
|
|
|
<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
|
2000-08-18 12:03:50 +00:00
|
|
|
handle bigger numbers, take a look at the <link
|
|
|
|
linkend="ref.bc">arbitrary precision math functions</link>.
|
1999-06-06 18:51:02 +00:00
|
|
|
</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>
|
2000-04-09 11:28:05 +00:00
|
|
|
<row>
|
|
|
|
<entry>M_PI</entry>
|
|
|
|
<entry>3.14159265358979323846</entry>
|
|
|
|
<entry>Der Wert π (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>
|
2000-08-21 09:37:33 +00:00
|
|
|
<row>
|
|
|
|
<entry>M_SQRTPI</entry>
|
|
|
|
<entry>1.77245385090551602729</entry>
|
|
|
|
<entry>sqrt(pi) [CVS]</entry>
|
|
|
|
</row>
|
2000-04-09 11:28:05 +00:00
|
|
|
<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>
|
2000-08-21 09:37:33 +00:00
|
|
|
<row>
|
|
|
|
<entry>M_SQRT3</entry>
|
|
|
|
<entry>1.73205080756887729352</entry>
|
|
|
|
<entry>sqrt(3) [CVS]</entry>
|
|
|
|
</row>
|
2000-04-09 11:28:05 +00:00
|
|
|
<row>
|
|
|
|
<entry>M_SQRT1_2</entry>
|
|
|
|
<entry>0.70710678118654752440</entry>
|
|
|
|
<entry>1/sqrt(2)</entry>
|
|
|
|
</row>
|
2000-08-21 09:37:33 +00:00
|
|
|
<row>
|
|
|
|
<entry>M_LNPI</entry>
|
|
|
|
<entry>1.14472988584940017414</entry>
|
|
|
|
<entry>log_e(pi) [CVS]</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>M_EULER</entry>
|
|
|
|
<entry>0.57721566490153286061</entry>
|
|
|
|
<entry>Euler constant [CVS]</entry>
|
|
|
|
</row>
|
1999-06-06 18:51:02 +00:00
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
2000-04-09 11:28:05 +00:00
|
|
|
Only M_PI is available in PHP versions up to and including PHP4RC1.
|
2000-08-21 09:37:33 +00:00
|
|
|
All other constants are available starting with PHP4.0. Constants
|
|
|
|
labelled [CVS] only available in the CVS code for PHP4.
|
1999-06-06 18:51:02 +00:00
|
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
</sect1>
|
|
|
|
</partintro>
|
|
|
|
|
|
|
|
<refentry id="function.abs">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>abs</refname>
|
|
|
|
<refpurpose>Absolute value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>mixed <function>abs</function></funcdef>
|
|
|
|
<paramdef>mixed <parameter>number</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns the absolute value of number. If the argument number is
|
2000-07-23 19:07:54 +00:00
|
|
|
float, return type is also float, otherwise it is int.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.acos">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>acos</refname>
|
|
|
|
<refpurpose>Arc cosine</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>acos</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the arc cosine of arg in radians.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>asin</function> and <function>atan</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.asin">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>asin</refname>
|
|
|
|
<refpurpose>Arc sine</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>asin</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the arc sine of arg in radians.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>acos</function> and <function>atan</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.atan">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>atan</refname>
|
|
|
|
<refpurpose>Arc tangent</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>atan</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the arc tangent of arg in radians.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>asin</function> and <function>acos</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.atan2">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>atan2</refname>
|
1999-06-06 18:51:02 +00:00
|
|
|
<refpurpose>arc tangent of two variables</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>atan2</function></funcdef>
|
|
|
|
<paramdef>float <parameter>y</parameter></paramdef>
|
|
|
|
<paramdef>float <parameter>x</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2000-07-23 19:07:54 +00:00
|
|
|
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>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>acos</function> and <function>atan</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.base-convert">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>base_convert</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Convert a number between arbitrary bases</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
2000-08-25 03:16:54 +00:00
|
|
|
<funcdef>string <function>base_convert</function></funcdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
<paramdef>string <parameter>number</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>frombase</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>tobase</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</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>
|
2000-07-23 19:07:54 +00:00
|
|
|
<title><function>Base_convert</function></title>
|
1999-10-20 22:41:42 +00:00
|
|
|
<programlisting role="php">
|
2000-07-23 19:07:54 +00:00
|
|
|
$binary = base_convert ($hexadecimal, 16, 2);
|
1999-06-06 18:51:02 +00:00
|
|
|
</programlisting>
|
2000-07-23 19:07:54 +00:00
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
|
|
|
|
<refentry id="function.bindec">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>bindec</refname>
|
|
|
|
<refpurpose>Binary to decimal</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>bindec</function></funcdef>
|
|
|
|
<paramdef>string <parameter>binary_string</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns the decimal equivalent of the binary number represented by
|
2000-07-23 19:07:54 +00:00
|
|
|
the binary_string argument.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Octdec converts a binary number to a decimal number. The largest
|
1999-06-06 18:51:02 +00:00
|
|
|
number that can be converted is 31 bits of 1's or 2147483647 in
|
2000-07-23 19:07:54 +00:00
|
|
|
decimal.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
See also the <function>decbin</function>
|
2000-07-23 19:07:54 +00:00
|
|
|
function.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.ceil">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>ceil</refname>
|
|
|
|
<refpurpose>Round fractions up</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>ceil</function></funcdef>
|
|
|
|
<paramdef>float <parameter>number</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
|
|
Returns the next highest integer value from
|
|
|
|
<parameter>number</parameter>. Using <function>ceil</function>
|
2000-07-23 19:07:54 +00:00
|
|
|
on integers is absolutely a waste of time.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
NOTE: PHP/FI 2's <function>ceil</function> returned a
|
|
|
|
float. Use: <literal>$new = (double)ceil($number);</literal> to
|
2000-07-23 19:07:54 +00:00
|
|
|
get the old behaviour.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2000-08-18 12:03:50 +00:00
|
|
|
See also <function>floor</function> and
|
|
|
|
<function>round</function>.
|
2000-07-23 19:07:54 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.cos">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>cos</refname>
|
|
|
|
<refpurpose>Cosine</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>cos</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the cosine of arg in radians.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>sin</function> and <function>tan</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.decbin">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>decbin</refname>
|
|
|
|
<refpurpose>Decimal to binary</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>decbin</function></funcdef>
|
|
|
|
<paramdef>int <parameter>number</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns a string containing a binary representation of the given
|
|
|
|
number argument. The largest number that can be converted is
|
2000-07-23 19:07:54 +00:00
|
|
|
2147483647 in decimal resulting to a string of 31 1's.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also the <function>bindec</function> function.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.dechex">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>dechex</refname>
|
|
|
|
<refpurpose>Decimal to hexadecimal</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>dechex</function></funcdef>
|
|
|
|
<paramdef>int <parameter>number</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns a string containing a hexadecimal representation of the
|
|
|
|
given number argument. The largest number that can
|
2000-07-23 19:07:54 +00:00
|
|
|
be converted is 2147483647 in decimal resulting to "7fffffff".
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also the <function>hexdec</function> function.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.decoct">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>decoct</refname>
|
|
|
|
<refpurpose>Decimal to octal</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>decoct</function></funcdef>
|
|
|
|
<paramdef>int <parameter>number</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns a string containing an octal representation of the given
|
|
|
|
number argument. The largest number that can be converted is
|
2000-07-23 19:07:54 +00:00
|
|
|
2147483647 in decimal resulting to "17777777777".
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>octdec</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-07-23 19:07:54 +00:00
|
|
|
<refentry id="function.deg2rad">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>deg2rad</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Converts the number in degrees to the radian equivalent
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
2000-07-23 19:07:54 +00:00
|
|
|
<funcdef>double <function>deg2rad</function></funcdef>
|
|
|
|
<paramdef>double <parameter>number</parameter></paramdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
</funcprototype>
|
2000-07-23 19:07:54 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
This function converts <parameter>number</parameter> from degrees
|
|
|
|
to the radian equivalent.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>rad2deg</function>.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2000-04-09 11:28:05 +00:00
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.exp">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>exp</refname>
|
|
|
|
<refpurpose>e to the power of ...</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>exp</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns e raised to the power of <parameter>arg</parameter>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>pow</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.floor">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>floor</refname>
|
|
|
|
<refpurpose>Round fractions down</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>floor</function></funcdef>
|
|
|
|
<paramdef>float <parameter>number</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
|
|
Returns the next lowest integer value from
|
|
|
|
<parameter>number</parameter>. Using <function>floor</function>
|
2000-07-23 19:07:54 +00:00
|
|
|
on integers is absolutely a waste of time.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
NOTE: PHP/FI 2's <function>floor</function> returned a
|
|
|
|
float. Use: <literal>$new = (double)floor($number);</literal> to
|
2000-07-23 19:07:54 +00:00
|
|
|
get the old behaviour.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2000-08-18 12:03:50 +00:00
|
|
|
See also <function>ceil</function> and
|
|
|
|
<function>round</function>.
|
2000-07-23 19:07:54 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.getrandmax">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>getrandmax</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Show largest possible random value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>getrandmax</function></funcdef>
|
|
|
|
<paramdef>void </paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
|
|
Returns the maximum value that can be returned by a call to
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>rand</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>rand</function>, <function>srand</function>,
|
|
|
|
<function>mt_rand</function>, <function>mt_srand</function>, and
|
|
|
|
<function>mt_getrandmax</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.hexdec">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>hexdec</refname>
|
|
|
|
<refpurpose>Hexadecimal to decimal</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>hexdec</function></funcdef>
|
|
|
|
<paramdef>string <parameter>hex_string</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</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
|
2000-07-23 19:07:54 +00:00
|
|
|
can be converted is 7fffffff or 2147483647 in decimal.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also the <function>dechex</function> function.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.log">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>log</refname>
|
|
|
|
<refpurpose>Natural logarithm</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>log</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the natural logarithm of arg.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.log10">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>log10</refname>
|
|
|
|
<refpurpose>Base-10 logarithm</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>log10</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the base-10 logarithm of <parameter>arg</parameter>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.max">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>max</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Find highest value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>mixed <function>max</function></funcdef>
|
|
|
|
<paramdef>mixed <parameter>arg1</parameter></paramdef>
|
|
|
|
<paramdef>mixed <parameter>arg2</parameter></paramdef>
|
|
|
|
<paramdef>mixed <parameter>argn</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>max</function> returns the numerically highest of the
|
2000-07-23 19:07:54 +00:00
|
|
|
parameter values.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<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.
|
2000-07-23 19:07:54 +00:00
|
|
|
You can compare an unlimited number of values.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<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
|
2000-07-23 19:07:54 +00:00
|
|
|
an integer is returned.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.min">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>min</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Find lowest value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<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>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>Min</function> returns the numerically lowest of the
|
|
|
|
parameter values.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<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.
|
2000-07-23 19:07:54 +00:00
|
|
|
You can compare an unlimited number of values.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<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
|
2000-07-23 19:07:54 +00:00
|
|
|
an integer is returned.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.mt-rand">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mt_rand</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Generate a better random value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>mt_rand</function></funcdef>
|
2000-07-23 19:07:54 +00:00
|
|
|
<paramdef>int
|
|
|
|
<parameter><optional>min</optional></parameter>
|
2000-06-24 07:38:45 +00:00
|
|
|
</paramdef>
|
2000-07-23 19:07:54 +00:00
|
|
|
<paramdef>int
|
|
|
|
<parameter><optional>max</optional></parameter>
|
2000-06-24 07:38:45 +00:00
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</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
|
2000-01-18 15:13:04 +00:00
|
|
|
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>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2000-01-20 16:50:07 +00:00
|
|
|
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>.
|
2000-01-18 15:13:04 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
Remember to seed the random number generator before use with
|
2000-01-18 15:13:04 +00:00
|
|
|
<function>mt_srand</function>.
|
|
|
|
</simpara>
|
2000-01-20 16:50:07 +00:00
|
|
|
<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 und 15.
|
|
|
|
</para>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>mt_srand</function>,
|
2000-01-20 16:50:07 +00:00
|
|
|
<function>mt_getrandmax</function>, <function>srand</function>,
|
|
|
|
<function>rand</function> and <function>getrandmax</function>.
|
2000-01-18 15:13:04 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.mt-srand">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mt_srand</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Seed the better random number generator</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>void <function>mt_srand</function></funcdef>
|
|
|
|
<paramdef>int <parameter>seed</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2000-07-23 19:07:54 +00:00
|
|
|
</funcsynopsis>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Seeds the random number generator with
|
|
|
|
<parameter>seed</parameter>.
|
|
|
|
<informalexample>
|
2000-07-23 19:07:54 +00:00
|
|
|
<programlisting role="php">
|
1999-06-06 18:51:02 +00:00
|
|
|
// seed with microseconds since last "whole" second
|
2000-07-23 19:07:54 +00:00
|
|
|
mt_srand ((double) microtime() * 1000000);
|
1999-06-06 18:51:02 +00:00
|
|
|
$randval = mt_rand();
|
|
|
|
</programlisting>
|
2000-07-23 19:07:54 +00:00
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>mt_rand</function>,
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>mt_getrandmax</function>, <function>srand</function>,
|
|
|
|
<function>rand</function>, and
|
|
|
|
<function>getrandmax</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.mt-getrandmax">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mt_getrandmax</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Show largest possible random value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>mt_getrandmax</function></funcdef>
|
|
|
|
<paramdef>void </paramdef>
|
|
|
|
</funcprototype>
|
2000-07-23 19:07:54 +00:00
|
|
|
</funcsynopsis>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
Returns the maximum value that can be returned by a call to
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>mt_rand</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>mt_rand</function>,
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>mt_srand</function> <function>rand</function>,
|
|
|
|
<function>srand</function>, and
|
|
|
|
<function>getrandmax</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.number-format">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>number_format</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Format a number with grouped thousands</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<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>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>Number_format</function> returns a formatted version of
|
1999-06-06 18:51:02 +00:00
|
|
|
<parameter>number</parameter>. This function accepts either one,
|
|
|
|
two or four parameters (not three):
|
|
|
|
</para>
|
|
|
|
<para>If only one parameter is given,
|
2000-07-23 19:07:54 +00:00
|
|
|
<parameter>Number</parameter> will be formatted without decimals,
|
1999-06-06 18:51:02 +00:00
|
|
|
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>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>octdec</refname>
|
|
|
|
<refpurpose>Octal to decimal</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>octdec</function></funcdef>
|
|
|
|
<paramdef>string <parameter>octal_string</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</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
|
2000-07-23 19:07:54 +00:00
|
|
|
decimal.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>decoct</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.pi">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>pi</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Get value of pi</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>double <function>pi</function></funcdef>
|
|
|
|
<paramdef>void </paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns an approximation of pi.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.pow">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>pow</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Exponential expression</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>pow</function></funcdef>
|
|
|
|
<paramdef>float <parameter>base</parameter></paramdef>
|
|
|
|
<paramdef>float <parameter>exp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns base raised to the power of exp.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>exp</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-07-23 19:07:54 +00:00
|
|
|
<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>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
2000-07-23 19:07:54 +00:00
|
|
|
<funcdef>double <function>rad2deg</function></funcdef>
|
|
|
|
<paramdef>double <parameter>number</parameter></paramdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
</funcprototype>
|
2000-07-23 19:07:54 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
This function converts <parameter>number</parameter> from radian
|
|
|
|
to degrees.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>deg2rad</function>.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2000-04-09 11:28:05 +00:00
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.rand">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>rand</refname>
|
2000-01-18 15:13:04 +00:00
|
|
|
<refpurpose>Generate a random value</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>rand</function></funcdef>
|
|
|
|
<paramdef>
|
|
|
|
<parameter><optional>int min</optional></parameter>
|
|
|
|
</paramdef>
|
|
|
|
<paramdef>
|
|
|
|
<parameter><optional>int max</optional></parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2000-01-20 16:50:07 +00:00
|
|
|
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>.
|
2000-01-18 15:13:04 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
Remember to seed the random number generator before use with
|
2000-01-20 16:50:07 +00:00
|
|
|
<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 und 15.
|
|
|
|
</para>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>srand</function>,
|
2000-01-20 16:50:07 +00:00
|
|
|
<function>getrandmax</function>, <function>mt_rand</function>,
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>mt_srand</function>, and
|
2000-01-18 15:13:04 +00:00
|
|
|
<function>mt_getrandmax</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.round">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>round</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Rounds a float</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>double <function>round</function></funcdef>
|
|
|
|
<paramdef>double <parameter>val</parameter></paramdef>
|
2000-08-18 12:03:50 +00:00
|
|
|
<paramdef>int
|
|
|
|
<parameter><optional>precision</optional></parameter>
|
|
|
|
</paramdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-06-27 17:00:30 +00:00
|
|
|
Returns the rounded value of <parameter>val</parameter> to
|
2000-07-23 19:07:54 +00:00
|
|
|
specified precision.
|
1999-06-06 18:51:02 +00:00
|
|
|
<informalexample>
|
2000-07-23 19:07:54 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
$foo = round (3.4); // $foo == 3.0
|
|
|
|
$foo = round (3.5); // $foo == 4.0
|
|
|
|
$foo = round (3.6); // $foo == 4.0
|
2000-06-27 17:00:30 +00:00
|
|
|
|
2000-07-23 19:07:54 +00:00
|
|
|
$foo = round (1.95583, 2); // $foo == 1.96
|
1999-06-06 18:51:02 +00:00
|
|
|
</programlisting>
|
2000-07-23 19:07:54 +00:00
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>ceil</function> and
|
|
|
|
<function>floor</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.sin">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>sin</refname>
|
|
|
|
<refpurpose>Sine</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>sin</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the sine of arg in radians.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>cos</function> and <function>tan</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.sqrt">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>sqrt</refname>
|
|
|
|
<refpurpose>Square root</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>sqrt</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the square root of <parameter>arg</parameter>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.srand">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>srand</refname>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refpurpose>Seed the random number generator</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>void <function>srand</function></funcdef>
|
|
|
|
<paramdef>int <parameter>seed</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Seeds the random number generator with
|
|
|
|
<parameter>seed</parameter>.
|
|
|
|
<informalexample>
|
2000-07-23 19:07:54 +00:00
|
|
|
<programlisting role="php">
|
1999-06-06 18:51:02 +00:00
|
|
|
// seed with microseconds since last "whole" second
|
2000-07-23 19:07:54 +00:00
|
|
|
srand ((double) microtime() * 1000000);
|
1999-06-06 18:51:02 +00:00
|
|
|
$randval = rand();
|
|
|
|
</programlisting>
|
2000-07-23 19:07:54 +00:00
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>rand</function>,
|
2000-07-23 19:07:54 +00:00
|
|
|
<function>getrandmax</function>, <function>mt_rand</function>,
|
|
|
|
<function>mt_srand</function>, and
|
|
|
|
<function>mt_getrandmax</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.tan">
|
|
|
|
<refnamediv>
|
2000-07-23 19:07:54 +00:00
|
|
|
<refname>tan</refname>
|
|
|
|
<refpurpose>Tangent</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>tan</function></funcdef>
|
|
|
|
<paramdef>float <parameter>arg</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
Returns the tangent of arg in radians.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2000-07-23 19:07:54 +00:00
|
|
|
See also <function>sin</function> and <function>cos</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</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
|
2000-01-18 15:13:04 +00:00
|
|
|
sgml-default-dtd-file:"../../manual.ced"
|
1999-06-06 18:51:02 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|