#43267 [Opn->Bgs]: Error in Floating Point Operation
| From: | johannes@php.net | Date: | Mon, 12 Nov 2007 18:59:30 +0000 |
| Subject: | #43267 [Opn->Bgs]: Error in Floating Point Operation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119567@lists.php.net to get a copy of this message | ||
ID: 43267
Updated by: johannes@php.net
Reported By: armadillo at penguinfriends dot org
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: CentOS
PHP Version: 5.2.5
New Comment:
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.
.
Previous Comments:
------------------------------------------------------------------------
[2007-11-12 18:30:02] armadillo at penguinfriends dot org
Description:
------------
The is a bug in many php versions with a floating point operation.
Tested PHP-Versions: 4.4.1 (Debian Sarge (3.1)), 5.0.4 (OpenSuse 10.0
x86_64), 5.2.5 (CentOS 5). It is a conversion from float to int, which
doesn't work correct. See the reprocedure code and the expected result
for more.
When running it on the ssh-console on CentOS 5, on the native login
console, the following output will be generated:
setitimer: php (pid = 2731) provided invalid timeval it_value: sec = -1
tv_usec = 0
Hope this will help! ;)
Reproduce code:
---------------
<?php echo (int)(100*2.55); ?>
Expected result:
----------------
255
Actual result:
--------------
254
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43267&edit=1