IBM 15 Switch User Manual


 
138
Chapter 8
Numeric Functions
CLEM contains a number of commonly used numeric functions.
Function
Result
Description
NUM
Number
Used to negate NUM. Returns the corresponding number with
the opposite sign.
NUM1 + NUM2
Number
Returns the sum of NUM1 and NUM2.
code NUM2
Number
Returns the value of NUM2 subtracted from NUM1.
NUM1 * NUM2
Number
Returns the value of NUM1 multiplied by NUM2.
NUM1 / NUM2
Number
Returns the value of NUM1 di vided by NUM2.
INT1 div INT2
Number
Used to perform integer division. Returns the value of INT1
divided by INT2.
INT1 rem INT2
Number
Returns the remainder of INT1 divided by INT2. For example,
INT1 – (INT1 div INT2) * INT2.
INT1 mod INT2
Number
This function has been deprecated. Use the rem function
instead.
BASE ** POWER
Number
Returns BASE raised to the power POWER, where either
may be any number (ex cept that BASE must not be zero if
POWER is zero of any type other than integer 0). If POWER
is an integer, the computati on is perfo rmed by successively
multiplying powers of BASE. Thus, if BASE is an integer, the
result will be an integer. If POWER is integer 0, the result is
always a 1 of the same type as BASE. Otherwise, if POWER
is not an i nteger, the result is computed as exp(POWER *
log(BASE)).
abs(NUM)
Number
Returns the absolute value of NUM, which is always a number
of the same type.
exp(NUM)
Real
Returns e raised to the p ower NUM, where e is the base of
natural logarithms.
fracof(NUM)
Real
Returns the fractional part of NUM, dened as
NUM–intof(NUM).
intof(NUM)
Integer
Truncates its argument to an integer. It returns the integer of
the same sign as NUM and with the largest magnitude such
that abs(INT) <= abs(NUM).
log(NUM)
Real
Returns the natural (base e) logarithm of NUM, which must
not be a zero of any kind.
log10(NUM)
Real
Returns the base 10 logarithm of NUM, which mus t not be
a zero of any kind. This funct i on is dened as log(NUM) /
log(10).
negate(NUM)
Number
Used to negate NUM. Returns the corresponding number with
the opp
osite sign.
round(NUM)
Integer
Used to round NUM to an integer by taking intof(NUM+0.5) if
NUM is positive or intof(NUM–0.5) if NUM is negative.
sign(NUM)
Number
Used to determine the sign of NUM. This operation returns
–1, 0, or 1 if NUM i s an integer. If NUM is a real, it returns
–1.0, 0.0, or 1.0, depending on whether NUM is negative,
zero, or positive.
sqrt(NUM)
Real
Retur
ns the square root of NUM. NUM must be positive.
sum_n(LIST)
Number
Returns the sum of values from a list of numeric elds or null
if all of the eld values are null. For more information, see the
topic Summarizing Multiple Fields in Chapter 7 on p. 115.