php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3570 Decimal Increments to intergers product strange values
Submitted: 2000-02-22 11:09 UTC Modified: 2000-03-05 11:53 UTC
From: mitcheld at discover dot lpl dot london dot on dot ca Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.12 OS: Redhat Linux 6.1
Private report: No CVE-ID: None
 [2000-02-22 11:09 UTC] mitcheld at discover dot lpl dot london dot on dot ca
for ($x = 0 ; $x < 100; $x+=.1) {
	echo "$x<BR>\n";
}

Some numbers add up fine, other start moving at values different than the step:

53.5
53.6
53.7
53.8
53.9
54
54.1
54.200000000001
54.300000000001
54.400000000001
54.500000000001
54.600000000001
54.700000000001
54.800000000001
54.900000000001

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-05 11:53 UTC] sas at cvs dot php dot net
That's the way floating point numbers work. The observed behaviour is correct.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Oct 12 08:00:02 2026 UTC