A scalar numeric function that returns the natural logarithm of a given numeric expression.
SET a=1
WHILE a<11 {
&sql(SELECT {fn LOG(:a)} INTO :b)
IF SQLCODE'=0 {
WRITE !,"Error code ",SQLCODE
QUIT }
ELSE {
WRITE !,"Logarithm of ",a," = ",b }
&sql(SELECT ROUND({fn EXP(:b)},12) INTO :c)
IF SQLCODE'=0 {
WRITE !,"Error code ",SQLCODE
QUIT }
ELSE {
WRITE !,"Exponential of log ",b," = ",c
SET a=a+1 }
}
Note that the
ROUND function is needed here to correct for very small discrepancies caused by system calculation limitations. In the above example,
ROUND is set arbitrarily to 12 decimal digits for this purpose.