ID: 34539
Updated by: [EMAIL PROTECTED]
Reported By: roy dot name at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: windows
PHP Version: 5.1.0RC1
New Comment:
It is all still expected behavior, there is no bug here.
Previous Comments:
------------------------------------------------------------------------
[2005-09-19 03:22:05] roy dot name at gmail dot com
<?php
$test = 12.4;
if ( $test*3 == 37.2 ) {
echo 'True';
} else {
echo 'False'; # This is the out?
}
?>
If I change the Floating point values,for example:12.4,then,the result
is 37.2,and it can output the actual result
------------------------------------------------------------------------
[2005-09-18 06:25:34] [EMAIL PROTECTED]
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
-
------------------------------------------------------------------------
[2005-09-18 05:44:37] roy dot name at gmail dot com
Description:
------------
Why the (9.8*3 != 29.4)
see the code may know clear
Reproduce code:
---------------
<?php
$test = 9.8;
if ( $test*3 == 29.4 ) {
echo 'True';
} else {
echo 'False'; # This is the out?
}
# If the value of $test is many others value ,and '29.4' is
# the correct value,the program will out the True;
?>
Expected result:
----------------
Expected result:True
Actual result:
--------------
Actual result:
False
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34539&edit=1