TAL Reference Manual

Standard Functions
TAL Reference Manual526371-001
14-39
$SCALE Function
$SCALE Function
The $SCALE function moves the position of the implied decimal point by adjusting the
internal representation of a FIXED(
fpoint) expression.
fixed-expression
is a FIXED expression.
scale
is an INT constant in the range –19 to +19 that defines the number of positions to
move the implied decimal point to the left (
scale > 0) or to the right (scale < 0) of
the least significant digit.
Usage Considerations
If the result of the scale operation exceeds the range of a FIXED(0) expression,
$SCALE sets the overflow indicator.
$SCALE adjusts the implied decimal point of the stored value by multiplying or dividing
by 10 to the
scale power. Some precision might be lost with negative $SCALE values.
Example of $SCALE Function
1. In this example, $SCALE returns a FIXED(7) expression from a FIXED(3)
expression:
FIXED(3) a := 9.123F;
FIXED(7) result; !Declare variables
result := $SCALE (a, 4); !Return FIXED(7) value from
! FIXED(3) value
2. To retain precision when you divide operands that have nonzero fpoint settings,
use the $SCALE standard function to scale up the
fpoint of the dividend by a factor
equal to the fpoint of the divisor; for example:
FIXED(3) num, a, b; ! fpoint of 3
num := $SCALE (a,3) / b; !Scale A to FIXED(6); result
! is a FIXED(3) value
$SCALE
(
scale
)
fixed-expression
,
VST1441.vsd