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

 ID:                 63136
 User updated by:    tstobbe at sacbee dot com
 Reported by:        tstobbe at sacbee dot com
 Summary:            pow() returns NaN where base is negative and
                     exponent is an odd number root
 Status:             Open
 Type:               Bug
 Package:            Math related
 Operating System:   Linux (fc17, 32-bit)
 PHP Version:        5.4.7
 Block user comment: N
 Private report:     N

 New Comment:

It should be noted that all subsequent fractional pow() issues are related to 
this. For example: pow(-[any number], 1/5) vs pow(-[any number], 2/5). Likewise 
I suspect that most other exponent based functions (such as log with an 
arbitrary base) are probably suspect, but this hasn't been verified.


Previous Comments:
------------------------------------------------------------------------
[2012-09-21 22:38:15] tstobbe at sacbee dot com

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 this bug report at https://bugs.php.net/bug.php?id=63136&edit=1

Reply via email to