Bug #54334 [NEW]: The behavior for rounding to small presicion was changed and is against RFC
| From: | for-bugs at hnw dot jp | Date: | Mon, 21 Mar 2011 11:22:01 +0000 |
| Subject: | Bug #54334 [NEW]: The behavior for rounding to small presicion was changed and is against RFC | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-159668@lists.php.net to get a copy of this message | ||
From:
Operating system: Intel Linux and Intel MacOSX
PHP version: 5.3.6
Package: Math related
Bug Type: Bug
Bug description:The behavior for rounding to small presicion was changed and is against RFC
Description:
------------
The behavior of function round() was changed with revision 301991. So when
a small number is rounded to small precision, round() of PHP5.3.4-5.3.6
returns different value from PHP5.3.0-5.3.3. Additionally, the current
behavior is different from referred RFC(*1). I suppose it is not intended
change.
For example, test script returns "float(4.0E-60)" for PHP 5.3.0-5.3.3 and
PHP 5.2.17. However, PHP 5.3.4-5.3.6 shows "float(3.0E-60)".
This behavior changing was affected with revision 301991(*2) for fixing Bug
#52550(*3). However, I think this fix was useless.
Bug #52550 reports probability for integer overflow/underflow. However, the
C function php_intlog10abs() returns integer between -324 and 308 because
of property for IEEE754 64bit floating point numbers, so overflow/underflow
never occur for this part.
*1 http://wiki.php.net/rfc/rounding
*2
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/standard/math.c?r1=301991&r2=301990&pathrev=301991
*3 http://bugs.php.net/bug.php?id=52550
Test script:
---------------
<?php
var_dump(round(3.5e-60, 60));
Expected result:
----------------
float(4.0E-60)
Actual result:
--------------
float(3.0E-60)
--
Edit bug report at http://bugs.php.net/bug.php?id=54334&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54334&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54334&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54334&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54334&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54334&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54334&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54334&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54334&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54334&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54334&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54334&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54334&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54334&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54334&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54334&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54334&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54334&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54334&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54334&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54334&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54334&r=mysqlcfg