Faceți căutări pe acest blog

luni, 16 martie 2015

The effect of SET DECIMALS and arithmetic operations on number of decimals of the result

1) Variables
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 

vineri, 6 martie 2015

Adding supplementary pages at the end of the reports

It's easy to add one or more supplementary pages at the end of the report (after the last record).
For each such page, create a new group with EOF() as expression.
On the group footer band, tick Constant band height, and type a height big enough to force creating a new page.
Their group header band, can be used to add supplementary pages before the first record.