pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Example 263 $IFIX Routine
FIXED(2) fixnum;
INT intnum := 12345;
fixnum := $IFIX (intnum, 2); ! Return 123.45
$INT
$INT converts its argument to an INT value.
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
NoSets $OVERFLOW
expression
is an expression whose value is an INT, INT(32), UNSIGNED(1-16), UNSIGNED(17-31),
FIXED, REAL, REAL(64), SGBADDR, SGWADDR, SGXBADDR, SGXWADDR, or EXTADDR value.
If expression is not a FIXED, INT (64), REAL, or REAL(64) value, $INT returns the low-order
(rightmost) 16 bits of expression. $INT never causes overflow. $INT does not explicitly maintain
the sign of expression. In Example 264 (page 317), $INT returns -1 although the argument to
$INT is a positive number.
Example 264 $INT Routine
INT i;
i := $INT(%HFFFFFF%D);
If the value of the expression in Example 264 (page 317) is a FIXED, REAL, or REAL(64) value, $INT
returns the result of converting expression arithmetically to an INT value—$INT does not just truncate
an expression. If the converted value of expression is too large to fit in 16 bits, an exception trap
occurs.
For details on SG and SGX variables, see Chapter 3 (page 46).
Nonatomic Operations 317