'Why need to keep three decimal places ? two decimal places rounding problem

I am facing a problem rounding amounts into two decimal places. The total amount is not matching with breakdown amount

<ORDER_TOTAL_TAX>75.83</ORDER_TOTAL_TAX>

I know the total tax is 75.83 from the website backend. When I am breaking down this

75.83 => 15.83+14.165x2+15.835x2

75.83 => 75.83 // it matches accurately

but when I am rounding into two decimal places, I found the total is not matching

75.83 => 15.83+14.17x2+15.84x2

75.83 => 75.85 // it is not matching accurately

I must have to keep the breakdown into two decimal places. what should I do now? Please help me in this case



Solution 1:[1]

You should not be using values not inside Shopify. There is no such thing as a value of 14.165 inside Shopify, so don't pretend there is one.

You know perfectly well computers don't round consistently and that systems use the banking rule of some go up and some go down.

Use the numbers Shopify provides you and all your accounting makes sense. You use your own numbers and expect to be off by pennies here and there. That is life with computers. They do not do rounding the way you think they do.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Lazar