derick Mon Jun 16 14:31:34 2003 EDT
Modified files:
/phpdoc/en/reference/math/functions abs.xml base-convert.xml
ceil.xml floor.xml fmod.xml
hexdec.xml is-finite.xml
is-infinite.xml is-nan.xml
log.xml pi.xml round.xml
Log:
- Added tags, reordered info
Index: phpdoc/en/reference/math/functions/abs.xml
diff -u phpdoc/en/reference/math/functions/abs.xml:1.3
phpdoc/en/reference/math/functions/abs.xml:1.4
--- phpdoc/en/reference/math/functions/abs.xml:1.3 Sun Jun 30 06:41:42 2002
+++ phpdoc/en/reference/math/functions/abs.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.abs">
<refnamediv>
@@ -23,9 +23,11 @@
<title><function>abs</function> example</title>
<programlisting role="php">
<![CDATA[
+<?php
$abs = abs(-4.2); // $abs = 4.2; (double/float)
$abs2 = abs(5); // $abs2 = 5; (integer)
$abs3 = abs(-5); // $abs3 = 5; (integer)
+?>
]]>
</programlisting>
</example>
Index: phpdoc/en/reference/math/functions/base-convert.xml
diff -u phpdoc/en/reference/math/functions/base-convert.xml:1.2
phpdoc/en/reference/math/functions/base-convert.xml:1.3
--- phpdoc/en/reference/math/functions/base-convert.xml:1.2 Wed Apr 17 02:39:50
2002
+++ phpdoc/en/reference/math/functions/base-convert.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.base-convert">
<refnamediv>
@@ -27,9 +27,20 @@
<title><function>base_convert</function></title>
<programlisting role="php">
<![CDATA[
-$binary = base_convert ($hexadecimal, 16, 2);
+<?php
+$hexadecimal = 'A37334';
+echo base_convert($hexadecimal, 16, 2);
+?>
]]>
-</programlisting>
+ </programlisting>
+ <para>
+ Outputs:
+ </para>
+ <screen>
+<![CDATA[
+101000110111001100110100
+]]>
+ </screen>
</example>
</para>
</refsect1>
Index: phpdoc/en/reference/math/functions/ceil.xml
diff -u phpdoc/en/reference/math/functions/ceil.xml:1.4
phpdoc/en/reference/math/functions/ceil.xml:1.5
--- phpdoc/en/reference/math/functions/ceil.xml:1.4 Sun Jun 2 07:56:51 2002
+++ phpdoc/en/reference/math/functions/ceil.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.ceil">
<refnamediv>
@@ -19,15 +19,19 @@
<type>float</type> as the value range of <type>float</type> is
usually bigger than that of <type>integer</type>.
</simpara>
- <example>
- <title><function>ceil</function> example</title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title><function>ceil</function> example</title>
+ <programlisting role="php">
<![CDATA[
+<?php
echo ceil(4.3); // 5
echo ceil(9.999); // 10
+?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
<simpara>
See also <function>floor</function> and
<function>round</function>.
Index: phpdoc/en/reference/math/functions/floor.xml
diff -u phpdoc/en/reference/math/functions/floor.xml:1.4
phpdoc/en/reference/math/functions/floor.xml:1.5
--- phpdoc/en/reference/math/functions/floor.xml:1.4 Sun Jun 2 07:56:51 2002
+++ phpdoc/en/reference/math/functions/floor.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.floor">
<refnamediv>
@@ -19,15 +19,19 @@
<type>float</type> because the value range of <type>float</type> is
usually bigger than that of <type>integer</type>.
</simpara>
- <example>
- <title><function>floor</function> example</title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title><function>floor</function> example</title>
+ <programlisting role="php">
<![CDATA[
+<?php
echo floor(4.3); // 4
echo floor(9.999); // 9
+?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
<simpara>
See also <function>ceil</function> and
<function>round</function>.
Index: phpdoc/en/reference/math/functions/fmod.xml
diff -u phpdoc/en/reference/math/functions/fmod.xml:1.4
phpdoc/en/reference/math/functions/fmod.xml:1.5
--- phpdoc/en/reference/math/functions/fmod.xml:1.4 Fri Oct 25 20:29:33 2002
+++ phpdoc/en/reference/math/functions/fmod.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.fmod">
<refnamediv>
<refname>fmod</refname>
@@ -22,17 +22,21 @@
<parameter>x</parameter> and a magnitude less than the magnitude of
<parameter>y</parameter>.
</para>
- <example>
- <title>Using <function>fmod</function></title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title>Using <function>fmod</function></title>
+ <programlisting role="php">
<![CDATA[
+<?php
$x = 5.7;
$y = 1.3;
$r = fmod($x, $y);
// $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7
+?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/math/functions/hexdec.xml
diff -u phpdoc/en/reference/math/functions/hexdec.xml:1.3
phpdoc/en/reference/math/functions/hexdec.xml:1.4
--- phpdoc/en/reference/math/functions/hexdec.xml:1.3 Mon Jun 3 11:06:16 2002
+++ phpdoc/en/reference/math/functions/hexdec.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.16 -->
<refentry id="function.hexdec">
<refnamediv>
@@ -27,13 +27,15 @@
<title><function>hexdec</function> example</title>
<programlisting role="php">
<![CDATA[
+<?php
var_dump(hexdec("See"));
var_dump(hexdec("ee"));
-// both prints "int(238)"
+// both print "int(238)"
var_dump(hexdec("that"));
var_dump(hexdec("a0"));
-// both prints int(160)
+// both print int(160)
+?>
]]>
</programlisting>
</example>
Index: phpdoc/en/reference/math/functions/is-finite.xml
diff -u phpdoc/en/reference/math/functions/is-finite.xml:1.2
phpdoc/en/reference/math/functions/is-finite.xml:1.3
--- phpdoc/en/reference/math/functions/is-finite.xml:1.2 Wed Apr 17 02:39:52
2002
+++ phpdoc/en/reference/math/functions/is-finite.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.72 -->
<refentry id='function.is-finite'>
<refnamediv>
@@ -16,6 +16,10 @@
<para>
Returns &true; if <parameter>val</parameter> is a legal finite
number within the allowed range for a PHP float on this platform.
+ </para>
+ <para>
+ See also <function>is_infinite</function> and
+ <function>is_nan</function>.
</para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/math/functions/is-infinite.xml
diff -u phpdoc/en/reference/math/functions/is-infinite.xml:1.2
phpdoc/en/reference/math/functions/is-infinite.xml:1.3
--- phpdoc/en/reference/math/functions/is-infinite.xml:1.2 Wed Apr 17 02:39:52
2002
+++ phpdoc/en/reference/math/functions/is-infinite.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.72 -->
<refentry id='function.is-infinite'>
<refnamediv>
@@ -17,6 +17,10 @@
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>
+ <para>
+ See also <function>is_finite</function> and
+ <function>is_nan</function>.
</para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/math/functions/is-nan.xml
diff -u phpdoc/en/reference/math/functions/is-nan.xml:1.2
phpdoc/en/reference/math/functions/is-nan.xml:1.3
--- phpdoc/en/reference/math/functions/is-nan.xml:1.2 Wed Apr 17 02:39:53 2002
+++ phpdoc/en/reference/math/functions/is-nan.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.63 -->
<refentry id='function.is-nan'>
<refnamediv>
@@ -16,6 +16,10 @@
<para>
Returns &true; if <parameter>val</parameter> is 'not a number',
like the result of <literal>acos(1.01)</literal>.
+ </para>
+ <para>
+ See also <function>is_finite</function> and
+ <function>is_infinite</function>.
</para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/math/functions/log.xml
diff -u phpdoc/en/reference/math/functions/log.xml:1.7
phpdoc/en/reference/math/functions/log.xml:1.8
--- phpdoc/en/reference/math/functions/log.xml:1.7 Fri May 16 03:49:30 2003
+++ phpdoc/en/reference/math/functions/log.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.log">
<refnamediv>
@@ -30,11 +30,10 @@
log<subscript>b</subscript>(n) = log(n)/log(b), where log is the
neperian (or natural) logarithm.
</para>
- <para>
- See also
- <function>exp</function>.
- </para>
</note>
+ <para>
+ See also <function>exp</function>.
+ </para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/math/functions/pi.xml
diff -u phpdoc/en/reference/math/functions/pi.xml:1.2
phpdoc/en/reference/math/functions/pi.xml:1.3
--- phpdoc/en/reference/math/functions/pi.xml:1.2 Wed Apr 17 02:39:54 2002
+++ phpdoc/en/reference/math/functions/pi.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.pi">
<refnamediv>
@@ -24,8 +24,10 @@
<informalexample>
<programlisting>
<![CDATA[
+<?php
echo pi(); // 3.1415926535898
echo M_PI; // 3.1415926535898
+?>
]]>
</programlisting>
</informalexample>
Index: phpdoc/en/reference/math/functions/round.xml
diff -u phpdoc/en/reference/math/functions/round.xml:1.3
phpdoc/en/reference/math/functions/round.xml:1.4
--- phpdoc/en/reference/math/functions/round.xml:1.3 Sat Jun 1 21:54:25 2002
+++ phpdoc/en/reference/math/functions/round.xml Mon Jun 16 14:31:33 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry id="function.round">
<refnamediv>
@@ -20,34 +20,55 @@
<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>
+ <example>
+ <title><function>round</function> examples</title>
<programlisting role="php">
<![CDATA[
+<?php
echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
+echo round(5.045, 2); // 5.04
+echo round(5.055, 2); // 5.06
+?>
]]>
</programlisting>
- </informalexample>
+ </example>
+ </para>
+ <para>
+ <caution>
+ <simpara>
+ When rounding on exact halves <function>round</function> rounds down on
+ evens and up on odds. If you want to always force it in one direction
+ on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The
+ reason behind rounding half the values down and the other half up is to
+ avoid the classical banking problem where if you always rounded down
+ you would be stealing money from your customers, or if you always
+ rounded up you would end up over time losing money. By averaging it
+ out through evens and odds you statistically break even.
+ </simpara>
+ </caution>
+ </para>
+ <para>
+ <note>
+ <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>
+ </note>
+ </para>
+ <para>
+ <note>
+ <simpara>
+ The <parameter>precision</parameter> parameter is only
+ available in PHP 4.
+ </simpara>
+ </note>
</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>.
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php