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:

One further note, in the repro above, it has to be exactly 16 nines.  by
adding or removing a 9, it does not fail.



Also, as far as I know, all of the failures have been on 32bit Intel
cpu's.  This probably will not fail on a 64bit cpu.


Previous Comments:
------------------------------------------------------------------------
[2010-03-27 12:22:12] codeslinger at compsalot dot com

well, it's hard to prove a negative.



but I have run a bunch of tests on the Linux snapshot and it appears to
be working fine.  A VERY BIG THANKYOU



I did not find any windows snapshots, the latest is 5.2.13 from Feb 24.



based on the symptoms, my initial assumption was that this was caused by
some kind of array corruption, this turned out to be wrong.  the actual
repro can be boiled down to one line...  :-)



echo (string) (double) -0.09999999999999999;





With the caveat that there are other values which also trigger this.

------------------------------------------------------------------------
[2010-03-26 21:37:12] paj...@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------
[2010-03-26 21:32:51] codeslinger at compsalot dot com

as far as the low incidence of occurrence and the millions of users not
seeing it.



I've said all along that it is hard to reproduce.  But when dealing with
financial transactions, that is not good enough, it only takes one
mistake to have a huge problem on your hands.



Out of all of those millions of users, I'd venture to say that the very
overwhelming majority are using php for string processing not number
crunching.  And in many cases where it does show up such as positioning
something on a web page, it would be easy to shrug off.  So there is no
way to know how often this happens in the wild, based on user feedback.

------------------------------------------------------------------------
[2010-03-26 21:02:47] codeslinger at compsalot dot com

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

------------------------------------------------------------------------
[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.

------------------------------------------------------------------------


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

Reply via email to