|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43267 Error in Floating Point Operation
Submitted: 2007-11-12 18:30 UTC Modified: 2007-11-12 18:59 UTC
From: armadillo at penguinfriends dot org Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.5 OS: CentOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: armadillo at penguinfriends dot org
New email:
PHP Version: OS:


 [2007-11-12 18:30 UTC] armadillo at penguinfriends dot org
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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-12 18:59 UTC]
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:
Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 08:01:32 2024 UTC