php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55426 pow() claims to return FALSE but actually does not
Submitted: 2011-08-15 19:10 UTC Modified: 2011-08-17 10:50 UTC
From: alex dot schuch at gmx dot de Assigned: bjori (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: -/-
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alex dot schuch at gmx dot de
New email:
PHP Version: OS:

 

 [2011-08-15 19:10 UTC] alex dot schuch at gmx dot de
Description:
------------
---
From manual page: http://www.php.net/function.pow%23Changelog
---
The manual says that pow() returns FALSE on error. Furthermore, it states that 
"PHP stops to emit a warning if the value can't be computed, it will now 
silently return FALSE only." since PHP 4.2.0.

I checked the source code of PHP 4.2.0, PHP 5.2 and PHP 5.3 and I simply cannot 
find a case where FALSE is returned. I even tried values like INF, NAN, -INF, 0, 
1.5, -1.5, array(), new stdClass(), TRUE, FALSE, NULL for the arguments $base 
and $exp, but FALSE is never returned.

The result can be an integer, a float, or a pseudo-float like INF, NAN or -INF, 
but just never FALSE.

a) Is the documentation still right when stating that pow() can return FALSE?

EDIT: I just checked the the source code of PHP 4.0.7 and there, FALSE can be 
returned.

Conclusion: Since PHP 4.2.0, no warning is emitted anymore, but neither can a 
FALSE be returned. It simply will return NAN on error.

Expected result:
----------------
Remove the line "If the power cannot be computed FALSE will be returned instead." 
and instead add "Be aware that non-finite values can be returned like INF, -INF or 
NAN in case of an error like overflow or underflow."

"Since 4.2.0	- PHP stops to emit a warning if the value can't be computed, it will 
now silently return FALSE only." should be changed to "Since 4.2.0 - PHP stops to 
emit a warning and return FALSE if the value can't be computer, it will return 
INF, -INF or NAN in case of an error."


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-17 10:50 UTC] bjori@php.net
Automatic comment from SVN on behalf of bjori
Revision: http://svn.php.net/viewvc/?view=revision&revision=315057
Log: Sort the changelog properly, kill bogus warning and wrong error return value. fixes bug#55426
 [2011-08-17 10:50 UTC] bjori@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: bjori
 [2011-08-17 10:50 UTC] bjori@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.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 06:00:01 2026 UTC