php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21458 simple calcul have strange result
Submitted: 2003-01-06 05:16 UTC Modified: 2003-01-06 06:20 UTC
From: bibifoc23 at yahoo dot fr Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.0 OS: linux and windows
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: bibifoc23 at yahoo dot fr
New email:
PHP Version: OS:

 

 [2003-01-06 05:16 UTC] bibifoc23 at yahoo dot fr
<?php

for ( $i=0.01;$i<0.2;$i+=0.01) {
  echo (15+$i-15)."\n";
}
?>

i should have:
 0.01
 0.02
 0.03
 0.04
 0.05
....
 0.19

but i get :
0.00999999999998
0.02
0.0299999999999
0.0399999999999
0.0500000000001
0.06
0.07
0.08
0.09
...
0.19

A test on linux RedHat 6.2 and Windows 2000 SP3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-06 06:20 UTC] georg@php.net
Actually this is documented:
http://www.php.net/manual/en/language.types.float.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 23 17:00:02 2025 UTC