pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
YesSets $OVERFLOW
fixed-expression
is the FIXED expression whose implied decimal point is to be changed.
scale
is an INT constant in the range -19 to +19 that specifies the number of positions to move the
implied decimal point with respect to the least significant digit. If scale is negative, the implied
decimal point moves to the left; if scale is positive, the implied decimal point moves to the
right.
$SCALE adjusts the implied decimal point of the stored FIXED value by multiplying or dividing the
value by 10 to the scale power. Some precision might be lost with negative scale values.
If the result of the scale operation exceeds the range of a FIXED expression, $SCALE traps if
overflow traps are enabled (see Chapter 13 (page 234)); otherwise, $SCALE ignores the problem.
Example 300 $SCALE Routine
FIXED(3) a := 9.123F;
FIXED(7) result;
result := $SCALE (a, 4); ! Return FIXED(7) value from
! FIXED(3) value
To retain precision when you divide operands that have nonzero fpoint settings, use the $SCALE
built-in routine to scale up the fpoint of the dividend by a factor equal to the fpoint of the
divisor, as in Example 301 (page 341).
Example 301 Using the $SCALE Routine to Maintain Precision
FIXED(3) num, a, b; ! fpoint of 3
num := $SCALE (a,3) / b; ! Scale a to FIXED(6); result is a
! FIXED(3) value
$SGBADDR_TO_EXTADDR
$SGBADDR_TO_EXTADDR converts an SGBADDR or SGXBADDR address to an EXTADDR address.
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
NoSets $OVERFLOW
Nonatomic Operations 341