#33576 [Opn->Bgs]: 19.6*100 != 19.6*10*10
| From: | derick@php.net | Date: | Tue, 05 Jul 2005 18:13:09 +0000 |
| Subject: | #33576 [Opn->Bgs]: 19.6*100 != 19.6*10*10 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81415@lists.php.net to get a copy of this message | ||
ID: 33576
Updated by: derick@php.net
Reported By: rick at ninjafoo dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: Gentoo Linux
PHP Version: 4.3.11
New Comment:
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.
.
Previous Comments:
------------------------------------------------------------------------
[2005-07-05 20:11:18] rick at ninjafoo dot com
Description:
------------
100* certain values is not the same as 10*10* the same
value.
The following code should produce no output. I see output.
Reproduce code:
---------------
<?php
$value1 = 19.6*100;
$value2 = 19.6*10*10;
if ($value1 != $value2) {
echo 'funny, i thaught 100x was exactly the same as 10x10x....<br>';
echo 'value1='.$value1.', value2='.$value2.',';
}
?>
Expected result:
----------------
I expect nothing to happen.
Actual result:
--------------
funny, i thaught 100x was exactly the same as 10x10x....
value1=1960, value2=1960,
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33576&edit=1