06-13-2012, 05:44 AM
Floating point calculations are not completely precise. For example, 0.03+0.02+0.01 gives result 0.060000000000000005. You can use function Round() to make it 0.06.
Macro Macro1756
Same in other languages, eg VBScript.
Macro Macro1758
Macro Macro1756
double Amount
;Amount=0.06
Amount=0.03+0.02+0.01
out
out "Amount: %.5G" Amount
out "Amount: %.20G" Amount ;;0.060000000000000005
if Amount=0.06;; <<<<<<<<<< ERROR <<<<<<<<<<
,out "OK"
else out "ERROR!"
Amount=Round(Amount 2)
if Amount=0.06
,out "OK"
else out "ERROR!"
Same in other languages, eg VBScript.
Macro Macro1758