php.net |  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
Votes:1
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
16 - 4 = ?
Subscribe to this entry?

 
 [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.

<?php
$base="2";
$exp="8";

echo pow($base,$exp);
?>

Gives me the error:

[28-May-2002 12:48:18] PHP Warning:  Invalid argument(s) passed to pow() in (....)/editMatrix.inc 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?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-28 16:01 UTC] edink@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net 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: Fri Apr 19 01:01:28 2024 UTC