Edit report at https://bugs.php.net/bug.php?id=60528&edit=1

 ID:                 60528
 Updated by:         larue...@php.net
 Reported by:        larue...@php.net
 Summary:            EG(precision) affects round function's behavior
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

hmm, seems you are right,  I should close this.


Previous Comments:
------------------------------------------------------------------------
[2011-12-15 09:55:16] bobwei9 at hotmail dot com

$ php -dprecision=20 -r 'echo 1.22;'

outputs: 1.2199999999999999734


I think it's only the floating point imprecision and not round()-specific.

------------------------------------------------------------------------
[2011-12-15 03:03:28] larue...@php.net

Description:
------------
as doc said:
precision:
   The number of significant digits displayed in floating point numbers.

so precision suppose to only affect the display format of a float;

but the fact is:

$php -dprecision=14 -r 'echo round(1.22, 2);'
1.22

php -dprecision=20 -r 'echo round(1.22, 2);'
1.2199999999999999734

the eg(precision) affected the round result.

Test script:
---------------
$php -dprecision=14 -r 'echo round(1.22, 2);'


php -dprecision=20 -r 'echo round(1.22, 2);'


Expected result:
----------------
1.22
1.22

Actual result:
--------------
1.22
1.2199999999999999734


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



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

Reply via email to