a) Multiplication
Number of decimal = sum(number of decimals)
b) Division
Number of decimals = max(SET(Decimals) + 2, sum(number of decimals))
2) Constants
a) Double constants
Number of decimals = max(SET(Decimals) , sum(number of decimals))
b) Integer constants
If the result is an integer then Number of decimals = 0
Else Number of decimals = SET(Decimals)
3) Power
Number of decimals (b ^ e) = max(SET(Decimals) , number of decimals(b))
(See http://www.tek-tips.com/viewthread.cfm?qid=1746336)
LOCAL setdec
setdec = SET("Decimals")
doit(0)
doit(1)
doit(2)
doit(3)
doit(4)
SET DECIMALS TO &setdec
PROCEDURE doit
LPARAMETERS setdec
LOCAL lnx
CLEAR
SET DECIMALS TO setdec
?"Set decimals to",SET("Decimals")
?
?"Multiplication"
lnx = PI()
? "lnx = " , lnx,"lnx ^ 2 = " , lnx ^ 2,"lnx ^ 2.231 = " , lnx ^ 2.231
lnx = lnx * 1
? "lnx = lnx * 1" , lnx ,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1.0
? "lnx = lnx * 1.0" , lnx ,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1.0
? "lnx = lnx * 1.0" , lnx ,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1.00
? "lnx = lnx * 1.00" , lnx ,"lnx ^ 2 = " , lnx ^ 2
? "multiplication between two double constants","3.1*3.1=", 3.1 * 3.1,"3.1 ^ 2 =",3.1 ^ 2
?
? "Division"
lnx = PI()
? "lnx = " , lnx
lnx = lnx / 1
? "lnx = lnx / 1" , lnx
lnx = lnx / 1.0
? "lnx = lnx / 1.0" , lnx
lnx = lnx / 1.0
? "lnx = lnx / 1.0" , lnx
lnx = lnx / 1.00
? "lnx = lnx / 1.00" , lnx
lnx = lnx / 1.000
? "lnx = lnx / 1.000" , lnx
lnx = lnx / 1.0000
? "lnx = lnx / 1.0000" , lnx
lnx = lnx / 1.00000
? "lnx = lnx / 1.00000" , lnx
lnx = lnx / 1.000000
? "lnx = lnx / 1.000000" , lnx
? "division between two double constants","3.1/3.1=", 3.1 / 3.1
?
?"Multiplication"
lnx = 1
? "lnx = " , lnx,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1
? "lnx = lnx * 1" , lnx ,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1.0
? "lnx = lnx * 1.0" , lnx ,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1.0
? "lnx = lnx * 1.0" , lnx ,"lnx ^ 2 = " , lnx ^ 2
lnx = lnx * 1.00
? "lnx = lnx * 1.00" , lnx ,"lnx ^ 2 = " , lnx ^ 2
? "multiplication between two integer constants","2*1=", 2*1,"1*2=", 1*2,"1 ^ 2 =",1 ^ 2
?
? "Division"
lnx = 1
? "lnx = " , lnx
lnx = lnx / 1
? "lnx = lnx / 1" , lnx
lnx = lnx / 1.0
? "lnx = lnx / 1.0" , lnx
lnx = lnx / 1.0
? "lnx = lnx / 1.0" , lnx
lnx = lnx / 1.00
? "lnx = lnx / 1.00" , lnx
lnx = lnx / 1.000
? "lnx = lnx / 1.000" , lnx
lnx = lnx / 1.0000
? "lnx = lnx / 1.0000" , lnx
lnx = lnx / 1.00000
? "lnx = lnx / 1.00000" , lnx
lnx = lnx / 1.000000
? "lnx = lnx / 1.000000" , lnx
? "division between two integer constants","2/1=", 2/1,"1/2=", 1/2
WAIT
ENDPROC
Niciun comentariu:
Trimiteți un comentariu