ID: 42835 Updated by: [EMAIL PROTECTED] Reported By: konrad at fumaco dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: Windows PHP Version: 5.2.4 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: ------------------------------------------------------------------------ [2007-10-03 05:54:24] konrad at fumaco dot com Description: ------------ $t is supposed to return 0. However, for some reason $x is not the same as $v. The problem only occurs with this number. Reproduce code: --------------- $x = (5.10 * 200); $v = 1020; $t = $x - $v; echo "x = ".$x ."<br>"; echo "v = ".$v ."<br>"; echo "t = ".$t ."<br>"; if($x==$v){ echo "yes"; } else { echo "no"; } Expected result: ---------------- x = 1020 v = 1020 t = 0 yes Actual result: -------------- x = 1020 v = 1020 t = -1.1368683772162E-13 no ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42835&edit=1