jeroen Tue Aug 7 18:40:54 2001 EDT
Modified files:
/phpdoc/en/language types.xml
Log:
- Some Double -> float's
- Some extra notes
Index: phpdoc/en/language/types.xml
diff -u phpdoc/en/language/types.xml:1.42 phpdoc/en/language/types.xml:1.43
--- phpdoc/en/language/types.xml:1.42 Fri Aug 3 15:22:34 2001
+++ phpdoc/en/language/types.xml Tue Aug 7 18:40:53 2001
@@ -1,4 +1,4 @@
-<!-- $Revision: 1.42 $ -->
+<!-- $Revision: 1.43 $ -->
<chapter id="language.types">
<title>Types</title>
@@ -29,7 +29,7 @@
<listitem>
<simpara>
- <link linkend="language.types.double">floating-point number (double)</link>
+ <link linkend="language.types.double">floating-point number (float)</link>
</simpara>
</listitem>
@@ -92,7 +92,7 @@
<simpara>
In parameter definitions you can also encounter the 'number' pseudo-type,
that indicates a parameter that is either <type>integer</type> or
- <type>double</type>.
+ <type>float</type>.
</simpara>
-->
</note>
@@ -202,7 +202,7 @@
> 0 (zero) </simpara>
</listitem>
<listitem>
- <simpara>the <link linkend="language.types.double">double</link>
+ <simpara>the <link linkend="language.types.double">float</link>
0.0 (zero) </simpara>
</listitem>
<listitem>
@@ -292,12 +292,13 @@
-->
The size of an integer is platform-dependent, although a
maximum value of about two billion is the usual value
- (that's 32 bits signed).
+ (that's 32 bits signed). PHP does not support unsigned
+ integers.
</para>
<note><!-- or warning? -->
<simpara>
In PHP there is no such thing as integer division. <literal>1/2</literal>
- yields the <type>double</type> <literal>0.5</literal>. <!-- See
+ yields the <type>float</type> <literal>0.5</literal>. <!-- See
??? for more information. (with the operators, or with type-jug) -->
</simpara>
</note>
@@ -307,7 +308,7 @@
<title>Integer overflow</title>
<para>
If you specify a number beyond the bounds of the <type>integer</type>-type,
- it will be interpreted as a <type>double</type> instead.
+ it will be interpreted as a <type>float</type> instead.
<informalexample>
<programlisting role="php">
$large_number = 2147483647;
@@ -315,18 +316,18 @@
// output: int(2147483647)
$large_number = 2147483648;
var_dump($large_number);
-// output: float(2147483648) <!--
+// output: float(2147483648)
-php is inconsistent here...
-vardump says float, gettype says double
+// this goes also for hexadecimal specified integers:
--->
+var_dump( 0x80000000 );
+// output: float(2147483648)
</programlisting>
</informalexample>
Furthermore, if some function or operator yields a number that is beyond
the boundaries of <type>integer</type>, it will also
be automatically converted to
- <type>double</type>.
+ <type>float</type>.
<informalexample>
<programlisting role="php">
$million = 1000000;
@@ -373,7 +374,7 @@
</simpara>
</sect3>
- <sect3 id="language.types.integer.casting.from-double">
+ <sect3 id="language.types.integer.casting.from-float">
<title>From <link linkend="language.types.double">floating point
numbers</link></title>
<simpara>
When converting from float to integer, the number will
@@ -443,7 +444,7 @@
<sect1 id="language.types.double">
<title>Floating point numbers</title>
<para>
- Floating point numbers (AKA "doubles", "floats" or "real numbers") can be
+ Floating point numbers (AKA "floats", "doubles" or "real numbers") can be
specified using any of the following syntaxes:
<synopsis>
$a = 1.234; $a = 1.2e3; $a = 7E-10;
@@ -455,7 +456,7 @@
EXPONENT_DNUM (({LNUM}|{DNUM})[eE][+-]?{LNUM})
-->
- The size of a floating point number is platform-dependent,
+ The size of a float is platform-dependent,
although a maximum of ~1.8e308 with a precision of roughly 14
decimal digits is a common value (that's 64 bit IEEE format).
</para>
@@ -942,7 +943,7 @@
value and type are determined as follows.
</simpara>
<simpara>
- The string will evaluate as a double if it contains any of the
+ The string will evaluate as a <type>float</type> if it contains any of the
characters '.', 'e', or 'E'. Otherwise, it will evaluate as an
integer.
</simpara>
@@ -1752,9 +1753,9 @@
</simpara>
<para>
An example of PHP's automatic type conversion is the addition
- operator '+'. If any of the operands is a double, then all
- operands are evaluated as doubles, and the result will be a
- double. Otherwise, the operands will be interpreted as integers,
+ operator '+'. If any of the operands is a float, then all
+ operands are evaluated as floats, and the result will be a
+ float. Otherwise, the operands will be interpreted as integers,
and the result will also be an integer. Note that this does NOT
change the types of the operands themselves; the only change is in
how the operands are evaluated.
@@ -1765,7 +1766,7 @@
$foo++; // $foo is the string "1" (ASCII 49)
-->
$foo += 2; // $foo is now an integer (2)
-$foo = $foo + 1.3; // $foo is now a double (3.3)
+$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)
<!--
@@ -1849,7 +1850,7 @@
<informalexample>
<programlisting role="php">
$foo = 10; // $foo is an integer
-$bar = (double) $foo; // $bar is a double
+$bar = (float) $foo; // $bar is a float
</programlisting>
</informalexample>
</para>
@@ -1863,7 +1864,7 @@
<simpara>(bool), (boolean) - cast to boolean</simpara>
</listitem>
<listitem>
- <simpara>(real), (double), (float) - cast to double</simpara>
+ <simpara>(float), (double), (real) - cast to float</simpara>
</listitem>
<listitem>
<simpara>(string) - cast to string</simpara>
@@ -1993,4 +1994,5 @@
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
+vim: ts=1 sw=1 et syntax=sgml
-->