IBM 15 Switch User Manual


 
141
CLEM Language Reference
Function
Result
Description
integer_bitcount(INT)
Integer
Counts t he number of 1 or 0 bits in the
two’s-complement representation of INT. If
INT is non-negative, N is the n umber of 1 bits. If
INT is negative, it is the number of 0 bits. Owing to
the sign extension, there are an innite number of 0
bits in a non-negative integer or 1 bits i n a negative
integer. It is always the case that integer_bitcount(INT)
= integer_bitcount(-(INT+1)).
integer_leastbit(INT)
Integer
Returns the bit position N of the least-signicant bit
set in the integer INT. N is the highe st power of 2 by
which INT divides exactly.
integer_length(INT)
Integer
Returns the lengt h in bits of INT as a two’s-complement
integer. That is , N i s the smal l est integer such that INT
< (1 << N) if INT >= 0 INT >= (–1 << N) if INT < 0. If
INT is non-negative, then the representation of INT as
an unsigned integer requires a eld of at least N bits.
Alternatively, a min i mum of N+1 bits is required to
represent INT as a signed integer, regardless of its sign.
testbit(INT, N)
Boolean
Tests the bit at position N in the integer INT and returns
the state of bit N as a Boolean value, which is true for 1
and false for 0.
Random Functions
The f ollowing functions are used to randomly select items or random ly generate numbers.
Function
Result
Description
oneof(LIST)
Any
Returns a randomly ch osen element of LIST. List items should
be entered as [ITEM1,ITEM2,...,ITEM_N]. Note that a list of eld
names can also be specied. For more information, see the
topic Summarizing Multiple Fields in Chapter 7 on p. 115.
random(NUM)
Number
Returns a uniformly distributed random number of the same type
(INT or REAL), startin g from 1 to NUM. If you use an integer,
then onl
y integers are returned . If you use a real (decimal)
number, then real numbers are returned (decimal precision
determined by the stream options). The largest random number
return
ed by the function could equal NUM.
random0(NUM)
Number
This has the same properties as random(NUM), but starting from
0. The largest random number returned by the function will
never equal X.
String Functions
In CLEM
, you can perform the fo llowing operations with strings:
Compare string s
Creat
e strings
Access characters