Previous Topic Next topic Print topic


INT Function

Purpose

Interprets specified storage as a signed integer and returns the value of that integer.

Syntax

INT(expression[,position[,length]])

Parameters

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.

Description

The INT function interprets the storage specified as a signed integer and returns the value of that integer. the INT 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.

INT returns a value of type Fixed Bin(31). If the field has a length of zero, INT returns zero.

INT and POSINT are identical functions, except that POSINT returns an unsigned 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.

Examples

DCL A BIT(32);

   A = '12345678'B4;
   PUT SKIP LIST(INT(A,5,4));
END TEST;

Restrictions

None.

Previous Topic Next topic Print topic