|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17492 pow() does not recognize integer numbers when cast as string
Submitted: 2002-05-28 15:51 UTC Modified: 2002-05-28 16:01 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: joe at intware dot tv Assigned:
Status: Closed Package: Math related
PHP Version: 4.2.1 OS: FreeBSD 4.5-RELEASE
Private report: No CVE-ID: None
 [2002-05-28 15:51 UTC] joe at intware dot tv
Here's code to replicate.  Please see note below as to why these are string values.


echo pow($base,$exp);

Gives me the error:

[28-May-2002 12:48:18] PHP Warning:  Invalid argument(s) passed to pow() in (....)/ on line 74


This may seem a low-priority issue, however, in a matrix project I'm working on the base/exponents are usually stored in a database, and the functions to retrieve them are usually typecast as strings when fetch()'ed and stored in an array.  I have to assign temporary variables with the value of the base and exponent re-assigned using settype([$tmp_base|$tmp_exp],"integer") in order to get pow() to work.  This does not seem like a 'clean' solution, could perhaps pow() be a little less strict as far as it's types, or is php heading towards stricter casting for all functions?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-28 16:01 UTC]
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at In case this was a documentation 
problem, the fix will show up soon at
In case this was a website problem, the change will show
up on the site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 17:01:29 2024 UTC