#42812 [NEW]: integer value returned by php incorrect
| From: | laurent at polenord dot com | Date: | Mon, 01 Oct 2007 10:33:31 +0000 |
| Subject: | #42812 [NEW]: integer value returned by php incorrect | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-118005@lists.php.net to get a copy of this message | ||
From: laurent at polenord dot com
Operating system: linux
PHP version: 5.2.4
PHP Bug Type: Scripting Engine problem
Bug description: integer value returned by php incorrect
Description:
------------
infact the problem occurs on PHP 5.2.3
I want to simply return a float multiplied by a million, and force it to
an integer value to avoid php returns int in weird format (2.9E+06 for
example), and it doesn't return the correct value.
This is very strange as it seems to occurs only on the '2.09' value : it's
ok with 1.09 and 3.09, 2.19, 2.091 and 2.089, etc...
Reproduce code:
---------------
$cpc = '2.09';
echo $cpc * 1000000; // returns correct value : 2090000
echo "<br/>";
echo (int)($cpc * 1000000); // returns 2089999 !!
echo "<br/>";
echo (int)($cpc * 1000 * 1000); // return correct value.
Expected result:
----------------
2090000
2090000
2090000
Actual result:
--------------
2090000
2089999
2090000
--
Edit bug report at http://bugs.php.net/?id=42812&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42812&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42812&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42812&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42812&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42812&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42812&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42812&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42812&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42812&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42812&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42812&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42812&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42812&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42812&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42812&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42812&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42812&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42812&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42812&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42812&r=mysqlcfg