ID:               47304
 Comment by:       p dot klein at letsmakesense dot de
 Reported By:      lennartvdd at mailordersolutions dot nl
 Status:           Assigned
 Bug Type:         Scripting Engine problem
 Operating System: win32 only
 PHP Version:      5.2.9
 Assigned To:      pajoye
 New Comment:

I experienced this issue using the number_format() and
round()-function. My example page displays items in a price list and
prices like '17' or '19' (only even numbers) were converted to '16.:'
and '18.:'. The weird thing was that every fourth reload the prices were
converted correctly to '17,00' and '19,00'. The situation improved after
I calculated the floats with BCMath functions. Now three out of four
conversions were correct.

Next thing I tried was to play with the precision setting of php. After
changing the value to '13' the conversion problem disappeared. But even
after changing it back to the default setting the issue hasn't occurred
anymore. 

I don't trust the situation. The bug probably still exists, but it's
very hard to reproduce. We didn't have the bug while we used version
5.2.0, but it happened with 5.2.12 and 5.3.1.

----------------
Our system:

Windows Server 2003 R2, Standard Edition, Service Pack 2
Intel Core 2 CPU 6600 @ 2.40 GHz, 3,99 GB RAM
PHP Version 5.2.12


Previous Comments:
------------------------------------------------------------------------

[2009-09-28 09:58:07] egorich at junik dot lv

Seems that it fixed with rolling back to php 5.2.5 to me.

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

[2009-06-22 16:21:28] ciudadsatan at hotmail dot com

The bug in Linux happens with
    echo 0.15-0.05;

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

[2009-06-22 03:47:55] ang dot chin dot han at gmail dot com

Originally from:

http://www.reddit.com/r/programming/comments/8tqpj/phpwtf_an_annoyance_
will_be_posted_each_day/c0aeg66

In short, in a Ubuntu Hardy 32 bit (64bit unaffected), 5.2.4 (with 
Ubuntu patches) a simple

  echo 1.0-0.5;

produces "0.0:" instead of "0.1" like in other platforms.

Not sure if it's the same bug as this is casting from float to string.

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

[2009-06-08 09:47:15] egorich at junik dot lv

So, any solutions to this? 
The problem also arises when i try to convert string to double, like:
$amount = double($amount);

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

[2009-03-20 22:44:12] egorich at junik dot lv

10 minutes passed and now I see "16.:" printed. Of course nothing is
changed at that time on the server...

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

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/47304

-- 
Edit this bug report at http://bugs.php.net/?id=47304&edit=1

Reply via email to