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
 [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: Thu Mar 28 15:01:29 2024 UTC