@Bobino, I agree that @steve_ssh is on the right track.
You are right that forcing the expression engine to use a specific level of rounding, via Round or SetPrecision, does affect the outcome. Even so, there is a trick in that.
The output generated SetPrecision differs at each level. At some higher levels it will resolve to two decimal places.
And the output of Round only affects the number if it needs to be truncated.
Here is x with 48 decimal places:
x = 24.989999999999999999999999999999999999999999999999
Round ( x ; 48 ) => 24.989999999999999999999999999999999999999999999999
Here is x with 49 decimal places:
x = 24.9899999999999999999999999999999999999999999999999
Round ( x ; 48 ) => 24.99
and at 3 decimal places:
round( 24.989 ; 4 ) => 24.989
And here is the calculation engine working at several decimal places beyond the limit used in the SetPrecision function
GST = 10% sales tax
WET = 29% liquor tax
Let ( [
retail = 24.99
; gstRate = 1 / 10
; wetRate = 29 / 100
; exgst = SetPrecision ( retail / ( 1 + gstRate ) ; 18 )
; gst = SetPrecision ( exgst * gstRate ; 18)
; exwet = SetPrecision ( exgst / ( 1 + wetRate ) ; 18 )
; wet = SetPrecision ( exWet * wetRate ; 18 )
; recalcMultiply = SetPrecision ( exwet * (1 + wetRate ) * ( 1 + gstRate ) ; 299 )
; recalcAddition = SetPrecision ( exwet + wet + gst ; 299 )
24.989999999999999999628 < 21 decimal places
24.989999999999999999 < 18 decimal places