← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 882036] Re: rounding error

 

That's not a python bug, it is a ever-present problem when dealing with
float values, in every programming language.

As all information is, floats are represented as bits. As you have a fixed amount of bits in a float value, you have a finite number of possible representations, compared to infinite numbers and decimals in the real world numbers.
As described in http://en.wikipedia.org/wiki/IEEE_754-2008, in order to allow for a maximum of representable values, rounding issues can apply:

round() is a test for >= 0.5 (or later decimals, depending on
implementation)

But 2.675 is represented as a bit setting that is actually 2.67499999...
So the test for >= fails.

compare http://docs.python.org/tutorial/floatingpoint.html
That is also mentioned in the accounting mail linked above.

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP Project Group.
https://bugs.launchpad.net/bugs/882036

Title:
  rounding error

Status in OpenERP Server:
  New

Bug description:
  Concerns 6.0 and trunk.
  If you define a precision of 0.01, the rounding of 0.125 must be 0.13 and not 0.12. The error is in the call of the format string "%.2f"%val which introduces a mathematical error. The round function must be called to apply the correct rounding before formatting the string. It should be:
  "%.2f"%round(val*100)/100
  Fix class digits_change of class float in the server. BUT fix also the gtk client AND web client as they all have that error (I let you find the right line)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/882036/+subscriptions


References