php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9843 Decrement Operator
Submitted: 2001-03-19 14:46 UTC Modified: 2001-03-19 14:56 UTC
From: jplock at bigfoot dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: Linux
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: jplock at bigfoot dot com
New email:
PHP Version: OS:

 

 [2001-03-19 14:46 UTC] jplock at bigfoot dot com
I believe there is a problem with the decrement operator.

http://www.artemisgroup.com/test.php

$percentchange = .30;
while ($percentchange > -1){
  $percentchange -= .01;
  echo $percentchange;
}

zero is returned as -1.422473250301E-16 and 0.01 is returned as 0.0099999999999999. This seems incorrect to me.

Thanks

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-19 14:56 UTC] hholzgra@php.net
theese are typical rounding errors that
occure when dealing with decimal fractions
on binary based machines
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 13:01:35 2025 UTC