ID: 49187 Updated by: ras...@php.net Reported By: belanger dot b at gmail dot com Status: Bogus Bug Type: *Math Functions 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: ------------------------------------------------------------------------ [2009-08-07 07:54:07] j...@php.net Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. ------------------------------------------------------------------------ [2009-08-07 05:51:09] belanger dot b at gmail dot com Tested it with all values from previously rejected or ignored similar bug submissions (code and execution here) : http://www.benlg.com/test.php P.S.: intval('9.95'*100) == intval(9.95*100) == 994 ------------------------------------------------------------------------ [2009-08-07 05:20:11] belanger dot b at gmail dot com Description: ------------ intval is not returning the correct value for '995' echo number_format('9.95'*100,0,'',''); // output 995 echo intval('9.95'*100); // output 994 Sorry but the most up to date server at my disposition is version 5.2.5 POSSIBLY RELATED REFUSED BUGS... found by me : http://bugs.php.net/bug.php?id=1960 (set to closed) found by system : http://bugs.php.net/bug.php?id=37554 (set to bogus) http://bugs.php.net/bug.php?id=39900 (set to bogus) Reproduce code: --------------- echo number_format('9.95'*100,0,'','') .' and '. number_format('1.16'*100,0,'','') ."\n". intval('9.95'*100); .' and '. intval('1.16'*100); Expected result: ---------------- 995 and 116 995 and 116 Actual result: -------------- 995 and 116 994 and 115 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49187&edit=1