ID: 41106 Updated by: [EMAIL PROTECTED] Reported By: neel dot basu dot z at gmail dot net -Status: Feedback +Status: Bogus Bug Type: Math related Operating System: Windows PHP Version: 5.1.6 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-04-16 18:07:28] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.2-win32-latest.zip ------------------------------------------------------------------------ [2007-04-16 18:05:29] neel dot basu dot z at gmail dot net I am Using php 5.1.6 ------------------------------------------------------------------------ [2007-04-16 18:03:16] neel dot basu dot z at gmail dot net Description: ------------ Simple Expression but wrong output. Reproduce code: --------------- <?php $res1 = (1.2-0.1)-1.1;// = 1.1-1.1 -> Evaluates to Zero $res2 = (2.2-0.1)-2.1;// = 2.1-2.1 -> Also Evaluates to Zero echo $res1."\t".gettype($res1); echo "\n"; echo $res2."\t".gettype($res2); ?> Expected result: ---------------- 0 double 0 double Actual result: -------------- -2.22044604925E-016 double 0 double ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41106&edit=1