Dan Goldberg
2008-09-17 20:27:49 UTC
Hi all
I have looked up previous discussions on problems with round() but have not been able to solve this. I am getting unexpected results in my order entry program when calculating tax. Below is an example of the problem. Any suggestions will be much appreciated.
Dan
SET DECIMAL TO 3
MQTY = 3
MPRICE = 3.30
MGSTRATE = .05
MSUB = 0
MGST = 0
MMGST = 0
MMTEST = 0
MSUB = MQTY * MPRICE
MGST = MSUB * MGSTRATE
MMGST = ROUND(MGST,2)
MMTEST = ROUND(.495,2)
? MGST // variable = 0.495 before rounding
? MMGST // rounds to 0.49 but should be 0.50 ??
? MMTEST //rounds to 0.50 which is correct
I have looked up previous discussions on problems with round() but have not been able to solve this. I am getting unexpected results in my order entry program when calculating tax. Below is an example of the problem. Any suggestions will be much appreciated.
Dan
SET DECIMAL TO 3
MQTY = 3
MPRICE = 3.30
MGSTRATE = .05
MSUB = 0
MGST = 0
MMGST = 0
MMTEST = 0
MSUB = MQTY * MPRICE
MGST = MSUB * MGSTRATE
MMGST = ROUND(MGST,2)
MMTEST = ROUND(.495,2)
? MGST // variable = 0.495 before rounding
? MMGST // rounds to 0.49 but should be 0.50 ??
? MMTEST //rounds to 0.50 which is correct