#44204 [Opn->Bgs]: intval makes very big mistakes
| From: | derick@php.net | Date: | Thu, 21 Feb 2008 21:21:04 +0000 |
| Subject: | #44204 [Opn->Bgs]: intval makes very big mistakes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122559@lists.php.net to get a copy of this message | ||
ID: 44204
Updated by: derick@php.net
Reported By: bugs at kathaus dot nl
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: Linux
PHP Version: 5.2.5
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2008-02-21 21:12:46] crrodriguez at suse dot de
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That
also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2008-02-21 17:22:13] bugs at kathaus dot nl
Description:
------------
see a page I created to show this bug:
http://www.budgetdedicated.com/phpbug.php
Reproduce code:
---------------
for quick reproduction:
$v=18.82;
$v=$v*100;
$v=intval($v);
echo $v."\n"; // 1820 = OK
$v=18.81;
$v=$v*100;
$v=intval($v);
echo $v."\n"; // 1800 = BAD
Expected result:
----------------
intval (18.81*100) == 1881
Actual result:
--------------
1880
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44204&edit=1