From: easteregg at verfriemelt dot org Operating system: Linux and Windows PHP version: 5.4.14 Package: Math related Bug Type: Bug Bug description:failing to add 0.001 multiple times
Description: ------------ Hi, first some informations: vanilla php 5.4.14 without any changes from your website, and a php 5.4.13 on a linux host. C:\Users\Administrator>php -v PHP 5.4.12 (cli) (built: Feb 19 2013 21:26:17) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies root@verfriemelt:~# php -v PHP 5.4.13-1~dotdeb.1 (cli) (built: Mar 21 2013 08:29:56) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies ------------ i have a number like 8 and add 0.001 while this number reaches 11. i suspected the numbers in between should look like 8.999 and 10.743 but instead i got some like this: 8.9899999999999 and i noticed a gap between some numbers. eg: 8.09 + 0.001 equals 8.090999999999 i suspected a problem with my linux box and tested it with my windows workstation, same result. so i guess its a php internal error. this doest not occur, when i simple add 0.001 to 8.09 so i guess it has something to do with the for() Test script: --------------- <?php for ($i = 8; $i< 11; $i += 0.001) { echo $i . "\n"; } Expected result: ---------------- [...] 8.08 8.081 8.082 8.083 8.084 8.085 8.086 8.087 8.088 8.089 8.09 8.091 8.092 8.093 8.094 8.095 8.096 8.097 8.098 8.099 8.1 [...] Actual result: -------------- 8.08 8.081 8.082 8.083 8.084 8.085 8.086 [...] 8.087 8.088 8.089 8.09 8.0909999999999 8.0919999999999 8.0929999999999 8.0939999999999 8.0949999999999 8.0959999999999 8.0969999999999 8.0979999999999 8.0989999999999 8.0999999999999 8.1009999999999 [...] -- Edit bug report at https://bugs.php.net/bug.php?id=64682&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64682&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64682&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64682&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64682&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64682&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64682&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64682&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64682&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64682&r=support Expected behavior: https://bugs.php.net/fix.php?id=64682&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64682&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64682&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64682&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64682&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64682&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64682&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64682&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64682&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64682&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64682&r=mysqlcfg