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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC