From:             dbjm at comcast dot net
Operating system: Windows 2000 & Linux 9
PHP version:      4.3.2
PHP Bug Type:     Math related
Bug description:  pow() function return errors

Description:
------------
The pow() function returns incorrect numbers when using a negative number
base.

This is not a crisis to fix for me - I have worked around it.

Thanks for the great work on developing PHP.

Sincerely,

Dave

Reproduce code:
---------------
echo "pow(3.125, 3.125) = " . pow(3.125, 3.125). "<br>";
echo "pow(-3.125, 3.125) = " . pow(-3.125, 3.125). "<br>";
echo "pow(3.125, -3.125) = " . pow(3.125, -3.125). "<br>";
echo "pow(-3.125, -3.125) = " . pow(-3.125, -3.125). "<br>";


Expected result:
----------------
When the same calcualtion is made using Visual Basic the results are:

3.125 ^ 3.125 = 35.1889507775869 
-3.125 ^ 3.125 = -35.1889507775869
3.125 ^ -3.125 = 2.84180112763389E-02
-3.125 ^ -3.125 = -2.84180112763389E-02



Actual result:
--------------
Windows 2000:
pow(3.125, 3.125) = 35.1889507776
pow(-3.125, 3.125) = -1.#IND
pow(3.125, -3.125) = 0.0284180112763
pow(-3.125, -3.125) = -1.#IND

Linux 9:
pow(3.125, 3.125) = 35.188950777587
pow(-3.125, 3.125) = NAN
pow(3.125, -3.125) = 0.028418011276339
pow(-3.125, -3.125) = NAN


-- 
Edit bug report at http://bugs.php.net/?id=25751&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25751&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25751&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25751&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25751&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25751&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25751&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25751&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25751&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25751&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25751&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25751&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25751&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25751&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25751&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25751&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25751&r=float

Reply via email to