diff --git a/language/types.xml b/language/types.xml index 47cec1a18b..ac4831c84d 100644 --- a/language/types.xml +++ b/language/types.xml @@ -1,4 +1,4 @@ - + Types @@ -29,7 +29,7 @@ - floating-point number (double) + floating-point number (float) @@ -92,7 +92,7 @@ In parameter definitions you can also encounter the 'number' pseudo-type, that indicates a parameter that is either integer or - double. + float. --> @@ -202,7 +202,7 @@ if ($show_separators) > 0 (zero) - the double + the float 0.0 (zero) @@ -292,12 +292,13 @@ $a = 0x1A; # hexadecimal number (equivalent to 26 decimal) --> 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. In PHP there is no such thing as integer division. 1/2 - yields the double 0.5. @@ -307,7 +308,7 @@ $a = 0x1A; # hexadecimal number (equivalent to 26 decimal) Integer overflow If you specify a number beyond the bounds of the integer-type, - it will be interpreted as a double instead. + it will be interpreted as a float instead. $large_number = 2147483647; @@ -315,18 +316,18 @@ var_dump($large_number); // output: int(2147483647) $large_number = 2147483648; var_dump($large_number); -// output: float(2147483648) +var_dump( 0x80000000 ); +// output: float(2147483648) Furthermore, if some function or operator yields a number that is beyond the boundaries of integer, it will also be automatically converted to - double. + float. $million = 1000000; @@ -373,7 +374,7 @@ var_dump($large_number); - + From <link linkend="language.types.double">floating point numbers</link> When converting from float to integer, the number will @@ -443,7 +444,7 @@ echo (int) ( (0.1+0.7) * 10 ); // echoes 7! Floating point numbers - 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: $a = 1.234; $a = 1.2e3; $a = 7E-10; @@ -455,7 +456,7 @@ DNUM ([0-9]*[\.][0-9]+)|([0-9]+[\.][0-9]*) 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). @@ -942,7 +943,7 @@ $last = $str{strlen($str)-1}; value and type are determined as follows. - The string will evaluate as a double if it contains any of the + The string will evaluate as a float if it contains any of the characters '.', 'e', or 'E'. Otherwise, it will evaluate as an integer. @@ -1752,9 +1753,9 @@ $var = Null; 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 = "0"; // $foo is string (ASCII 48) $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)