php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1960 intval() mangling values
Submitted: 1999-08-04 14:27 UTC Modified: 1999-08-04 14:38 UTC
From: leon at clearink dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.12 OS: Solaris
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: leon at clearink dot com
New email:
PHP Version: OS:

 

 [1999-08-04 14:27 UTC] leon at clearink dot com
<?
	print(intval(1.16*100));
?>

This code should return "116", but it returns "115".  I can't get it to mess up any value other than 1.16.

This is the work-around I'm using:

<?
	print(intval(1.16*100 + 0.0001));
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-04 14:38 UTC] rasmus at cvs dot php dot net
Fact of life when dealing with floating point numbers.  See my explanation of this here:
http://www.progressive-comp.com/Lists/?l=php3-general&m=93230944323512&w=2
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 19:01:28 2025 UTC