From: ben at bbbsystems dot net Operating system: Free BSD 5.3 PHP version: 5.1.2 PHP Bug Type: *Math Functions Bug description: intVal broken for calculated 1999
Description: ------------ This bug is for the function intVal( ), and I also found that typecasting with (int) produces the same results. This is a very weird bug I encountered because of a price that is 19.99 and our processor requires it to be sent as 1999. 1999 is the only value I was able to find that doesn't work correctly, but I'm sure there are others. I also checked it on a linux system with an older version of php 4 and got the same results. I upgraded our php to 5.1.2 then tried it again after it failed. I suspect the bug to be a floating point issue, but I'm not certain of it. -Ben Laurienti BBB Systems, LLC Reproduce code: --------------- <?php $test1 = intVal(1999); $amount = 19.99 * 100; $test2 = intVal($amount);//value is 1998 $test3 = intVal("$amount");//value is 1999 echo $test1 . "<br />\n"; echo $test2 . "<br />\n"; echo $test3 . "<br />\n"; ?> Expected result: ---------------- 1999 1999 1999 Actual result: -------------- 1999 1998 1999 -- Edit bug report at http://bugs.php.net/?id=36039&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36039&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36039&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36039&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36039&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36039&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36039&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36039&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36039&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36039&r=support Expected behavior: http://bugs.php.net/fix.php?id=36039&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36039&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36039&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36039&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36039&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36039&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36039&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36039&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36039&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36039&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36039&r=mysqlcfg