Edit report at http://bugs.php.net/bug.php?id=51396&edit=1
ID: 51396 Comment by: codeslinger at compsalot dot com Reported by: codeslinger at compsalot dot com Summary: Math is Unreliable Status: Bogus Type: Bug Package: Math related Operating System: any PHP Version: Irrelevant New Comment: P.S. Please note that in my own testing I have verified that the presence or absence of the xdebug and zend debug extensions do not alter the behavior of this bug, this was verified on Windows. Also note how for instance 5.2.4 fails on Windows and on Ubuntu but works on Mandriva (or at least was not found to fail on Mandriva). Also I can tell you from my own testing that the specific values which fail on Windows are very different from the specific values which fail on Unbuntu, when tested on the same computer. The only thing which can be said with some level of confidence is that all of the failures involve numbers with the digit 9 in them. Since these are 58? digit numbers and only a very few specific values fail, the potential to NOT see a failure is huge. Previous Comments: ------------------------------------------------------------------------ [2010-05-24 13:59:45] paj...@php.net Please read my last comment and provide the info I asked there. Without that, there is not a chance to get anywhere regarding this issue. ------------------------------------------------------------------------ [2010-05-24 13:46:10] codeslinger at compsalot dot com In Summary: As Reported by Multiple People Windows XP (32 bit) PHP 5.2.4 Fails Windows XP (32 bit) PHP 5.2.5 Works Windows 2000 (32 bit) PHP 5.2.5 Works Windows XP (32 bit) PHP 5.2.9 Fails Windows 2000 (32 bit) PHP 5.2.9 Fails Windows 2000 (32 bit) PHP 5.2.11 Fails Windows 2003 (?? bit) PHP 5.2.12 Fails Windows 2003 (?? bit) PHP 5.2.13 Fails Ubuntu 8 (32bit) PHP 5.2.4 Fails Ubuntu 8 (32bit) PHP 5.2.9 (custom build) Works Ubuntu 9 (64bit) PHP 5.2.10 Works Mandriva 2008 (32bit & 64bit) PHP 5.2.4 Works Mandriva 2008 (32bit & 64bit) Unpatched PHP 5.2.5 Fails This bug has been reported by multiple people. The above list is the combination of my own testing plus what I found reported by other people. The windows oses are all using the STOCK BUILD as provided by php.net It is very important to understand that the specific values which fail are highly variable. A specific value which fails on one os/php version does not necessarily fail on a different combination of os+php, but a different value will fail instead. It is also important to realize that given the obscurity and variability of this bug, just because a particular version of php is reported as working, does not guarantee that the bug does not exist, it only says that so far no one has reported encountering a specific value which triggers this bug. All of the following are thought to influence the specific behavior and reproducibility of this bug. The number of cpu bits The operating system The specific version of php The compiler flags that were used to build php The "precision" setting for php The format specifier/precision in an sprintf statement sprintf versus implied (string) conversion It is also possible that the floating point hardware could have an influence on the reproducibility of this bug. Since the WORK-AROUND did not work for John, it would appear that we still have a problem which needs to be solved. ------------------------------------------------------------------------ [2010-05-24 03:17:36] john dot smith dot 1964 at gmail dot com This problem isn't fixed for us by adding "ini_set("precision", 16);". Our PHP install is stock off the website (5.2.4 and 5.2.13, for instance) and our box runs Windows 2003. ------------------------------------------------------------------------ [2010-05-24 02:18:46] paj...@php.net . ------------------------------------------------------------------------ [2010-05-24 02:04:27] codeslinger at compsalot dot com Yipee!!! at least I have finally found a work-around that I can live with!!! You can close this bug now. The Mandriva Devs seem to think that this is actually a GCC bug and that it is Dependant on the build flags used. You can read about it here. https://qa.mandriva.com/show_bug.cgi?id=37171 Thanks to John (above) for the link. A lot more reading/searching of this WELL KNOWN ISSUE finally lead me to here: http://www.mysqlperformanceblog.com/2008/01/10/php-vs-bigint-vs-float-conversion-caveat/ and here: http://www.farad.com.au/source_code/php/setting_floating_point_precision_src.php To cut to the chase, the actual work-around is to change the "precision". This solution was hinted at by my simplefail.php program (test option 20), but I was unaware of an ini setting that is available for this. The solution to all of this madness and it is very mad indeed... is to add the following in your php program. ini_set("precision", 16); End of Problem.... End of Bug... Like Good Day Eh? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=51396 -- Edit this bug report at http://bugs.php.net/bug.php?id=51396&edit=1