Bug #77139 [NEW]: intval gives wrong results
From: markus at senoner dot com
Operating system: Linux (any)
PHP version: Irrelevant
Package: *Math Functions
Bug Type: Bug
Bug description:intval gives wrong results
Description:
------------
Please try:
echo intval(8.2*1000);
echo intval(8.2*100);
echo intval(8.2*10);
echo intval(8.2*1);
result:
8200
819 <--- this is wrong!
82
8
happens in PHP 7.2 as well as in PHP 5.X
If 819 is the result of an internal representation of 8.2 as
8.199999..., than why does the first operation in this example not give
8199 ?!?
Expected result:
----------------
8.2*100 should give 820, not 819
--
Edit bug report at https://bugs.php.net/bug.php?id=77139&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77139&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77139&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77139&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77139&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77139&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77139&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77139&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77139&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77139&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77139&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77139&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77139&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77139&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77139&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77139&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77139&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77139&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77139&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77139&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77139&r=mysqlcfg
Thread (3 messages)
- markus at senoner dot com