Bug #63136 [NEW]: pow() returns NaN where base is negative and exponent is an odd number root
| From: | tstobbe at sacbee dot com | Date: | Fri, 21 Sep 2012 22:38:15 +0000 |
| Subject: | Bug #63136 [NEW]: pow() returns NaN where base is negative and exponent is an odd number root | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-173622@lists.php.net to get a copy of this message | ||
From: tstobbe at sacbee dot com
Operating system: Linux (fc17, 32-bit)
PHP version: 5.4.7
Package: Math related
Bug Type: Bug
Bug description:pow() returns NaN where base is negative and exponent is an odd number root
Description:
------------
Odd roots (3, 5, etc) of negative numbers passed to pow() result in NaN
rather
than the actual result. While this makes sense for even numbered roots
(sqrt and
what-not), it wrecks havoc on any system that actually uses arbitrary roots
of
negative numbers.
Example: -2*-2*-2 = -8; pow(-8, 1/3) should return -2
Test script:
---------------
var_dump(pow(-8, 1/3));
Expected result:
----------------
float(-2)
Actual result:
--------------
float(NAN)
--
Edit bug report at https://bugs.php.net/bug.php?id=63136&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63136&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63136&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63136&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63136&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63136&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63136&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63136&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63136&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63136&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63136&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63136&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63136&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63136&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63136&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63136&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63136&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63136&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63136&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63136&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63136&r=mysqlcfg