#25751 [Opn->Ana]: pow() function return errors
| From: | sniper@php.net | Date: | Sat, 04 Oct 2003 02:07:37 +0000 |
| Subject: | #25751 [Opn->Ana]: pow() function return errors | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969356506@lists.php.net to get a copy of this message | ||
ID: 25751
Updated by: sniper@php.net
Reported By: dbjm at comcast dot net
-Status: Open
+Status: Analyzed
-Bug Type: Math related
+Bug Type: Documentation problem
Operating System: Windows 2000 & Linux 9
PHP Version: 4.3.2
New Comment:
There are some documentation problems:
1. pow() no longer shows any errors, even if parameters are invalid
2. pow(-1,1.1) produces complex number which PHP does not support.
For dbjm at comcast dot net:
Look manual for "is_finite()" function.
Previous Comments:
------------------------------------------------------------------------
[2003-10-03 18:12:12] dbjm at comcast dot net
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 this bug report at http://bugs.php.net/?id=25751&edit=1