Community mailing list archives
Re: Rounding issueby
Thanks a ton for your help. Very well explained. Will follow the guide line and revert you.
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...You should read https://docs.oracle.com/
cd/E19957-01/806-3568/ncg_ goldberg.htmlOnce 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 <firstname.lastname@example.org> wrote:
Greetings for the Day!
I am facing with rounding value problem. Please see below scenario.
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
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