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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joe at intware dot tv
New email:
PHP Version: OS:

 

 [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-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 18:03:34 2021 UTC