Bug #52892 [NEW]: Casting/rounding problem
| From: | vahe at spir dot me | Date: | Mon, 20 Sep 2010 11:25:34 +0000 |
| Subject: | Bug #52892 [NEW]: Casting/rounding problem | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-154504@lists.php.net to get a copy of this message | ||
From:
Operating system: Debian GNU/Linux 5.0.5 (lenny)
PHP version: Irrelevant
Package: *Math Functions
Bug Type: Bug
Bug description:Casting/rounding problem
Description:
------------
After adding 10 times 0.1 and casting it into int or flooring it return
value is 0
instead of 1.
Test script:
---------------
$a = 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1;
print $a; // 1
print round($a); // 1
print (int)$a; // 0 instead of 1
print floor($a); // 0 instead of 1
var_dump($a); // float(1)
--
Edit bug report at http://bugs.php.net/bug.php?id=52892&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52892&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52892&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52892&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52892&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52892&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52892&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52892&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52892&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52892&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52892&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52892&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52892&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52892&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52892&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52892&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52892&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52892&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52892&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52892&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52892&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52892&r=mysqlcfg