I have scanned a large number of questions and answers around math.round /.floor/.truncate/.ceiling
but couldn't find a clear answer to my problem of rounding (with currency values)
.
I understand math.round / toeven / awayfromzero
but that doesn't seem to do it.
( in the following examples 1.88
is just any number an can be replaced with any other n.mm
value)
If the result of a calculation of "decimal / decimal"
is 1.88499
I need 1.88
as the rounded result. If the calculation gives 1.885499
I want 1.89 as the result of rounding (always rounding to two decimal digits)
.
Now, math.round(1.88499999,2)
Returns 1.89
though 0.00499999
is certainly BELOW the middle between 8
and 9
.
I understand that if the number is rounded from the last decimal digit up to the first, the result is understandable:
1.88499999 -> 1.8849999 -> 1.884999 -> 1.88499 -> 1.8849 -> 1.885 -> 1.89
However, from a fiscal Point of view, like for VAT calculations, that doesn't help at all.
The only way i can think of is to cut the number first behind the third decimal digit to round it then to 2 required digits. But isn't there a more elegant way?