Interprets specified storage as an unsigned integer and returns the value of that integer.
POSINT(expression[,position[,length]])
expression is a scalar expression or reference to connected storage. expression cannot be an array, structure, or named constant. position is a positive integer value specifying the position of the first bit in the field; length is a positive integer value in the range 0 – 32 specifying the length of the field.
DCL A BIT(32); A = '12345678'B4; PUT SKIP LIST(POSINT(A,5,4)); END TEST;
None.
Description
The POSINT function interprets the storage specified as an unsigned integer and returns the value of that integer. The POSINT function does not perform conversion, so that the value returned depends on the data type of the variable contained in the specified storage.
If position is specified, its minimum value is 1 and its maximum value is the length in bits of the storage specified by expression. If position is omitted, the default value is 1.
If length is specified, its minimum value is 0 and its maximum value is the length in bits of the storage specified by expression, less the value of position. If length is omitted, the default value is equal to the number of bits from the bit indicated by position to the end of the storage specified by expression.
If position and length are not specified, the length of the storage referenced by expression cannot exceed 32 bits.
POSINT returns a value of type Fixed Bin(31). If the field has a length of zero, POSINT returns zero. Because POSINT returns an unsigned integer, it is possible for the value returned to be too large for assignment to Fixed Bin(31). The result of such an operation is undefined.
POSINT and INT are identical functions, except that INT returns a signed integer.
The result of this function is dependent on the native byte ordering of the hardware you are using. For this reason, the use of this function may not be portable across different platforms.