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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 23:01:30 2024 UTC