#34539 [Bgs->Opn]: tqjs
| From: | roy dot name at gmail dot com | Date: | Mon, 19 Sep 2005 01:22:06 +0000 |
| Subject: | #34539 [Bgs->Opn]: tqjs | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-85219@lists.php.net to get a copy of this message | ||
ID: 34539
User updated by: roy dot name at gmail dot com
Reported By: roy dot name at gmail dot com
-Status: Bogus
+Status: Open
Bug Type: Unknown/Other Function
Operating System: windows
PHP Version: 5.1.0RC1
New Comment:
<?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
Previous Comments:
------------------------------------------------------------------------
[2005-09-18 06:25:34] alan_k@php.net
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