TAL Reference Manual

Standard Functions
TAL Reference Manual526371-001
14-5
Rounding by Standard Functions
Rounding by Standard Functions
Type-transfer functions that have names ending in R, such as $DBLR, round the result.
All other type-transfer functions truncate the result.
The functions round values as follows:
(IF
value < 0 THEN value - 5 ELSE value + 5) / 10
That is, if the result is negative, 5 is subtracted; if positive, 5 is added. Then, an integer
division by 10 truncates the result. Therefore, if the absolute value of the least
significant digit of the result after initial truncation is 5 or more, a one is added to the
absolute value of the final least significant digit.
Rounding has no effect on INT, INT(32), or FIXED(0) expressions.
Scope of Standard Functions
You can use the following standard functions at the global level because they return
constant values:
$BITLENGTH
$BITOFFSET
$LEN
$OCCURS
$OFFSET
$TYPE
You can use all other standard functions only at the local or sublocal levels.
Expression Arguments
Many standard functions accept expressions as arguments. The following guidelines
regarding the data type and signedness of expressions apply to all standard functions
that accept expressions as arguments.
FIXED $FIXI
$FIXL
$INT
$INTR
$DBL
$DBLR
$FIXD
$FIX
$FIXR
$FLT
$FLTR
$EFLT
$EFLTR
REAL $INT
$INTR
$DBL
$DBLR
$FIX
$FIXR
-$EFLT
$EFLTR
REAL (64) $INT
$INTR
$DBL
$DBLR
$FIX
$FIXR
$FLT
$FLTR
-
Table 14-2. Type-Transfer Functions by Data Type (page 2 of 2)
Result
Expression INT INT (32) FIXED REAL REAL (64)