php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #25751 pow() function return errors
Submitted: 2003-10-03 18:12 UTC Modified: 2004-02-22 15:07 UTC
From: dbjm at comcast dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dbjm at comcast dot net
New email:
PHP Version: OS:

 

 [2003-10-03 18:12 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-03 22:07 UTC] sniper@php.net
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.

 [2004-02-22 15:07 UTC] nlopess@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of nlopess
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=d6bc44b4bf2a8d3663c82c0aa992b4bb3c8be434
Log: fix #25751 added bcpow and gmp_pow to see also
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 19:01:32 2024 UTC