General information
Title:
SET DECIMAL AND TRANSFORM
I use SET DECIMAL TO 6 to display with TRANSFORM() number with 6 decimals. I
have note that "SET DECIMAL TO " modify the result. Why ? The FoxPro
documentation play:
SET DECIMALS
Specifies the number of decimal places displayed in numeric
expressions.
Example 1 with SET DECIMAL TO 6
============================
set decimal to 6
w_PRICE = 3.047
w_SC1 = 0
w_SC2 = 0
w_VAL = (w_PRICE*(100-w_SC1)/100)*(100-w_SC2)/100
w_result = round(105.000 * w_VAL,2)
? w_result
? transform(w_result,"999999.999999")
ERROR !!! w_RESULT is 319.93. The correct result is 319.94
Example 2 with SET DECIMAL TO 5
============================
set decimal to 5
w_PRICE = 3.047
w_SC1 = 0
w_SC2 = 0
w_VAL = (w_PRICE*(100-w_SC1)/100)*(100-w_SC2)/100
w_result = round(105.000 * w_VAL,2)
? w_result
? transform(w_result,"999999.999999")
OK !!! w_RESULT is 319.94.
Thanks,
Maurizio
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only