Community mailing list archives

Re: Rounding issue

Akretion, Raphael Valyi
- 10/06/2016 21:07:18
Sorry I forgot: the floating point tools I just mentioned are to be found and documented in

On Thu, Oct 6, 2016 at 10:05 PM, Raphaël Valyi <> wrote:
Hello Prasad,

this is because Odoo usig floating point arithmetic. Basically numbers are represented in base 2 and what looks like a finite represention in base the decimal world (base 10) like 20% of something finite is actually like a non non finite representation in base 2, like 1/3 in base 10. Leading to precision loss and these rounding errors...

Once you understand this you should use float_round(value, precision_rounding=epsilon) and float_compare(value1, value2, precision_digits=None, precision_rounding=None) methods from  smartly to compare float numbers.

Ideally Odoo would have used a decimal package, but that is has been long debated and this is not what Odoo SA opted for. Thus what looks simple computation now requires some deep numerical computation understanding to avoid such errors, specially in the accounting where moves should be balanced...

Hope this helps.

On Thu, Oct 6, 2016 at 9:47 PM, Prasad Kabbur <> wrote:

Hi ,

Greetings for the Day!

I am facing with rounding value problem. Please see below scenario.

X= 893.23

Now I subtract Y and Z from X

Will get 777.24

Now I will dived into 3 parts
A=49.5% of 80% of 777.24
B=20%of80% 777.24


When final sum this

Y+Z+A+B+C  I am getting
.01 difference which on the screen so posting of account entry showing unbalanced. The height is I am not able trace the difference in code. I had put error message in the code when there is difference but showing error but showing difference on screen

Please he'll


Post to:


Raphaël Valyi
Founder and consultant
+55 21 3942-2434