I was adding up some numbers in my report and noticed something was a bit off. It seems that all rounding (in the form of number formats) is done after calculations are performed, leading to discrepancies such as this:
The total amount due here is one cent less than it should be. The key calculations I’m using to calculate these values are:
I know this must be due to the fact that “HST” is actually calculated as 374.4091 rather than 374.41 and FuelTax being calculated as 70.2455 rather than 70.25.
After looking through the reporting manual however, I can only find the function “round(float)” which is described as rounding to the nearest whole number.
Is there a way I can round to two decimal places before doing calculations?