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: Feedback Type: Bug Package: Math related Operating System: any PHP Version: Irrelevant New Comment: The billing program was failing on multiple computers at multiple locations, it failed on XP and Windows 2000 with various cpus. Those were customer sites! I reproduced the problem on a vmware setup with windows 2000. This snowflake program is failing on Ubuntu Hardy 8.0.4 with all of the updates. This is the stock php that comes with Ubuntu. This is a Pentium M 32bit Laptop. I've never experienced a memory error on this computer and the fact of it's consistency would argue against this being some kind of hardware issue. Here is what I get when I run the simplefail in the default config. php -v PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan 6 2010 22:01:14) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans with Zend Debugger v5.2.15, Copyright (c) 1999-2008, by Zend Technologies ========== php simplefail.php Selected onepair.txt, Found 1 items (string)(double) -0.1 === -0.1 which of course is correct But when we convert the value in an array it fails Conversion Error: PHP Math idx = 0 || '-0.1' !== '-0.0:' ===== THANK YOU I REALLY APPRECIATE THE HELP Previous Comments: ------------------------------------------------------------------------ [2010-03-26 17:25:40] ahar...@php.net Well, it is the next character after '9', and the character string is built up in zend_dtoa() by adding a value L (presumably intended to be in the range 0..9) to '0'. If L somehow ends up being 10, you'd get a colon. With the values that are apparently causing problems (the problematic value in onepair.txt is 0.09999999999999999167...), it does kind of look like a rounding issue to me, although I've no idea why it's not being triggered by more than two or three users in that case. ------------------------------------------------------------------------ [2010-03-26 17:18:22] ras...@php.net Bad memory perhaps? But why consistently a ':' ? ------------------------------------------------------------------------ [2010-03-26 16:57:15] ahar...@php.net JFTR, I was also unable to reproduce the failure case from any of the data files on both 32-bit and 64-bit Linux builds and a 32-bit Windows build. I've got a couple of boxen crunching away generating random doubles and converting them to strings in what seems to be the sort of range that causes problems (one 32-bit Linux, one 64-bit Linux): nothing yet after a couple of billion iterations. In short, I don't have a clue what it could be either, but I'll keep the random double generation going a while longer just in case it hits paydirt. ------------------------------------------------------------------------ [2010-03-26 16:39:33] paj...@php.net Rasmus, he is not the only person. There are two other reports about it. However he is the first one to experience it on non windows platform. ------------------------------------------------------------------------ [2010-03-26 16:26:05] ras...@php.net I ran your simplefail.php on all 4 data files. Never saw the failure case. Then I took just the huge rawpairs.txt file (had to increase the memory_limit) and modified your program slightly to do: for($i=0;$i<100000;$i++) ConvertData($data); and ran that, which took quite a while. Still no failures. You are still the only person who has ever reported these weird ":" characters showing up, and you have yet to produce any sort of code that reproduces it for someone else. We'll keep trying, but something that happens for 1 person out of millions is suspicious. ------------------------------------------------------------------------ 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