ID: 44204 Comment by: crrodriguez at suse dot de Reported By: bugs at kathaus dot nl Status: Open Bug Type: Variables related Operating System: Linux PHP Version: 5.2.5 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-02-21 17:22:13] bugs at kathaus dot nl Description: ------------ see a page I created to show this bug: http://www.budgetdedicated.com/phpbug.php Reproduce code: --------------- for quick reproduction: $v=18.82; $v=$v*100; $v=intval($v); echo $v."\n"; // 1820 = OK $v=18.81; $v=$v*100; $v=intval($v); echo $v."\n"; // 1800 = BAD Expected result: ---------------- intval (18.81*100) == 1881 Actual result: -------------- 1880 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44204&edit=1