# Community mailing list archives

#### Re: Rounding issue

by
Akretion, Raphael Valyi
- 10/06/2016 21:05:16

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.

Suppose
X= 893.23
Y=63.92
Z=50.07

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
C=10.5%of80%777.24

A=482.15475
B=194.81
C=102.27525

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

Regards

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

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

by