IBM 15 User Manual

Page of 270
141
CLEM Language Reference
Function
Result
Description
integer_bitcount(INT)
Integer
Counts the number of 1 or 0 bits in the
two’s-complement representation of INT. If
INT is non-negative, is the number of 1 bits. If
INT is negative, it is the number of 0 bits. Owing to
the sign extension, there are an infinite number of 0
bits in a non-negative integer or 1 bits in a negative
integer. It is always the case that
integer_bitcount(INT)
= integer_bitcount(-(INT+1)).
integer_leastbit(INT)
Integer
Returns the bit position of the least-significant bit
set in the integer INTis the highest power of 2 by
which INT divides exactly.
integer_length(INT)
Integer
Returns the length in bits of INT as a two’s-complement
integer. That is, is the smallest 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 field of at least bits.
Alternatively, a minimum 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 in the integer INT and returns
the state of bit as a Boolean value, which is true for 1
and false for 0.
Random Functions
The following functions are used to randomly select items or randomly generate numbers.
Function
Result
Description
oneof(LIST)
Any
Returns a randomly chosen element of LIST. List items should
be entered as
[ITEM1,ITEM2,...,ITEM_N]. Note that a list of field
names can also be specified. For more information, see the
topic
in Chapter 7 on p. 115.
random(NUM)
Number
Returns a uniformly distributed random number of the same type
(INT or REAL), starting from 1 to NUM. If you use an integer,
then only 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
returned 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 following operations with strings:
Compare strings
Create strings
Access characters