Bug #69517 [NEW]: round() does something weird on result of pow()
| From: | leafface at gmail dot com | Date: | Thu, 23 Apr 2015 18:45:22 +0000 |
| Subject: | Bug #69517 [NEW]: round() does something weird on result of pow() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-192303@lists.php.net to get a copy of this message | ||
From: leafface at gmail dot com
Operating system: Mac OS X
PHP version: 5.5.24
Package: Unknown/Other Function
Bug Type: Bug
Bug description:round() does something weird on result of pow()
Description:
------------
round() acts weird in some cases when pow() theoretically returns a
round number. The bug doesn't occur if precision for round() is set and
is greater than 14.
(Sorry, I actually have PHP 5.5.14, but it's pretty unlikely this has
been resolved since.)
Test script:
---------------
<pre>
<?
$n = pow(8, 2/3);
echo
($n == round($n) ? 'true' : 'false').
"\n".
($n == round($n, 14) ? 'true' : 'false').
"\n".
($n == round($n, 15) ? 'true' : 'false');
Expected result:
----------------
true
true
true
Actual result:
--------------
false
false
true
--
Edit bug report at https://bugs.php.net/bug.php?id=69517&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69517&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69517&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69517&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69517&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69517&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69517&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69517&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69517&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69517&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69517&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69517&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69517&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69517&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69517&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69517&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69517&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69517&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69517&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69517&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69517&r=mysqlcfg