ID:               36008
 Comment by:       troy20 at mail dot ru
 Reported By:      adi at rogers dot com
 Status:           Open
 Bug Type:         Math related
 Operating System: win32 only
 PHP Version:      5CVS-2006-06-14
 New Comment:

Code:
for ($i = 1.075;$i <= 1.975;$i=$i+0.1)
        {echo round($i,2);}
Result:
1.08, 1.18, 1.28, 1.38....
But if
        echo round(1.275,2);
        echo round(1.275*100);
we have 1.27 and 127. 

Another "same" example:
for ($i = 1.075;$i <= 20.975;$i=$i+0.1)
        {echo round($i,2);}

Win2003 + Apache 2.0.59 + php 5.1.6


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

[2006-06-14 22:11:53] adi at rogers dot com

Regretfully, the same output:

5.2.0-dev

Wrong: 14.37
Wrong: 14.37
'Magically' correct: 14.38
'Magically' correct: 14.38
Converted to string and is now correct: 14.38
Converted to string and is now correct: 14.38


The 32 precision results are also the same [as the ones on January 15].

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

[2006-06-14 15:50:08] [EMAIL PROTECTED]

Please try using this CVS snapshot:

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



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

[2006-01-15 06:40:25] adi at rogers dot com

Oh, and as I had suspected, here is the value of $num with 32
precision: 14.374999999999998
With 12 as the precision, it is: 14.375

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

[2006-01-15 06:34:25] adi at rogers dot com

As requested, the exact output with 32 as the precision:

Wrong: 14.369999999999999
Wrong: 14.37
'Magically' correct: 14.380000000000001
'Magically' correct: 14.38
Converted to string and is now correct: 14.369999999999999
Converted to string and is now correct: 14.37

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

[2006-01-14 16:06:25] [EMAIL PROTECTED]

What EXACTLY is the output when you set precision to 32?


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

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

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

Reply via email to