pTAL Reference Manual (H06.08+)
Built-In Routines
HP pTAL Reference Manual—523746-006
15-82
$SCALE
$SCALE
$SCALE moves the position of the implied fixed-point (decimal point) by changing a
FIXED(fpoint ) value.
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 Section 13, Hardware Indicators); otherwise,
$SCALE ignores the problem.
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 15-80 on page 15-83.
pTAL privileged procedure No
Can be executed only by privileged procedures No
Sets condition code No
Sets $CARRY No
Sets $OVERFLOW Yes
Example 15-79. $SCALE Routine
FIXED(3) a := 9.123F;
FIXED(7) result;
result := $SCALE (a, 4); ! Return FIXED(7) value from
! FIXED(3) value
( )
VST110.vsd
$SCALE ,
fixed-expression scale










