Bug #17492: pow() does not recognize integer numbers when cast as string
| From: | joe at intware dot tv | Date: | Tue, 28 May 2002 19:51:01 +0000 |
| Subject: | Bug #17492: pow() does not recognize integer numbers when cast as string | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-8796@lists.php.net to get a copy of this message | ||
From: joe@intware.tv
Operating system: FreeBSD 4.5-RELEASE
PHP version: 4.2.1
PHP Bug Type: Math related
Bug description: pow() does not recognize integer numbers when cast as string
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?
--
Edit bug report at http://bugs.php.net/?id=17492&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17492&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17492&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17492&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17492&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17492&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17492&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17492&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17492&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17492&r=globals