php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66288 pow() gives unexpected results if exponent is negative
Submitted: 2013-12-13 16:11 UTC Modified: 2013-12-14 00:20 UTC
From: mattT1227 at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.5.7 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mattT1227 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-12-13 16:11 UTC] mattT1227 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.pow
---
At least show example that negative exponents are not correctly implemented by pow.

Note, reporting system shows this problem has been suspended. It is still a problem. 

Test script:
---------------
echo pow(4, -2); // should be same as square root of 4


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-13 18:24 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2013-12-13 18:24 UTC] aharvey@php.net
pow() handles negative exponents fine: pow(4, -2) is 0.0625, which seems correct to me and also to Wolfram|Alpha: http://www.wolframalpha.com/input/?i=4^-2

Closing not a bug.
 [2013-12-13 22:15 UTC] rasmus@php.net
By the way, where is the suspended bug on this? We should mark that as Not-a-bug as well. 4^-2 is the same as 1/(4^2) which is most definitely not the same as the square root of 4. Where in the world did you get that from?
 [2013-12-14 00:20 UTC] datibbaw@php.net
The square root of 4 is calculated with a power of 1/2, i.e.

pow(4, 0.5) == float(2)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 13:01:32 2025 UTC