2 Test is_float() & it's FALIASes: is_double() & is_real() functions
5 if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
11 /* Prototype: bool is_float ( mixed $var );
12 * Description: Finds whether the given variable is a float
15 echo "*** Testing is_float(), is_double() and is_real() with float values***\n";
16 // different valid float values
18 -2147483649, // float value
19 2147483648, // float value
20 -0x80000001, // float value, beyond max negative int
21 0x800000001, // float value, beyond max positive int
22 020000000001, // float value, beyond max positive int
23 -020000000001, // float value, beyond max negative int
26 10.0000000000000000005,
49 /* loop to check that is_float(), is_double() & is_real() recognizes
50 different float values, expected: bool(true) */
52 foreach ($floats as $float ) {
53 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
54 var_dump( is_float($float) );
55 var_dump( is_double($float) );
56 var_dump( @is_real($float) );
59 echo "\n*** Testing is_float(), is_double() & is_real() with non float values ***\n";
60 // get a resource type variable
61 $fp = fopen (__FILE__, "r");
62 $dfp = opendir ( __DIR__ );
68 // non_scalar values, objects, arrays, resources and boolean
71 var $array = array(10.5);
109 1, // integers, hex and octal
118 @$unset_var, // unset variable
121 /* loop through the $not_floats to see working of
122 is_float(), is_double() & is_real() on objects,
123 arrays, boolean and others */
125 foreach ($not_floats as $value ) {
126 echo "--Iteration $loop_counter--\n"; $loop_counter++;
127 var_dump( is_float($value) );
128 var_dump( is_double($value) );
129 var_dump( @is_real($value) );
135 *** Testing is_float(), is_double() and is_real() with float values***
257 *** Testing is_float(), is_double() & is_real() with non float values ***