ID: 46233 Updated by: [EMAIL PROTECTED] Reported By: butterfly110Pro at yahoo dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: Windows 2003 Server R2 PHP Version: 5.2.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: ------------------------------------------------------------------------ [2008-10-05 07:38:58] butterfly110Pro at yahoo dot com Description: ------------ Salam, I Saw Differences Between Float Type Castings. My Trying Are Become Below, and This May Be Extensible For Other Numbers and Should Be Researches! Thanks. Reproduce code: --------------- echo (float)1199999 . '<br />'; echo (float)1200000 . '<br />'; echo (float)1200001 . '<br />'; echo (float)1300000 . '<br />'; echo (float)1399999 . '<br />'; echo (float)1400000 . '<br />'; echo (float)1400001 . '<br />'; echo '-------------------------<br />'; echo (float)11999999 . '<br />'; echo (float)12000000 . '<br />'; echo (float)12000001 . '<br />'; echo (float)13000000 . '<br />'; echo (float)13999999 . '<br />'; echo (float)14000000 . '<br />'; echo (float)14000001 . '<br />'; echo '-------------------------<br />'; echo (float)119999999 . '<br />'; echo (float)120000000 . '<br />'; echo (float)120000001 . '<br />'; echo (float)130000000 . '<br />'; echo (float)139999999 . '<br />'; echo (float)140000000 . '<br />'; echo (float)140000001 . '<br />'; Expected result: ---------------- 1199999 1200000 1200001 1300000 1399999 1400000 1400001 ------------------------- 11999999 12000000 12000001 13000000 13999999 14000000 14000001 ------------------------- 119999999 120000000 120000001 130000000 139999999 140000000 140000001 Actual result: -------------- 1199999 1.2E+6 1200001 1300000 1399999 1.4E+6 1400001 ------------------------- 11999999 1.2E+7 12000001 13000000 13999999 1.4E+7 14000001 ------------------------- 119999999 1.2E+8 120000001 130000000 139999999 1.4E+8 140000001 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46233&edit=1
