When the first parameter is a numeric or character expression,
the result has
precision digits and
decimal places decimal positions. The precision
and decimal places must be numeric literals, named constants that
represent numeric literals, or built-in functions with a numeric value
known at compile-time.
Note: %LEN and %DECPOS cannot be
used directly for the second and third parameters of %DEC or %DECH,
even if the values of %LEN and %DECPOS are constant. See
Figure 1 for an example using the length and decimal positions
of a variable to control %DEC and %DECH.
Parameters precision and decimal
places may be omitted if the type of expression is neither float
nor character. If these parameters are omitted, the precision and
decimal places are taken from the attributes of the numeric expression.
If the parameter is a character expression, the following rules
apply:
- The sign is optional. It can be '+' or '-'. It can precede or
follow the numeric data.
- The decimal point is optional. It can be either a period or a
comma.
- Blanks are allowed anywhere in the data. For example, ' + 3 '
is a valid parameter.
- The second and third parameters are required.
- Floating point data, for example '1.2E6', is not allowed.
- If invalid numeric data is found, an exception occurs with status
code 105.
See %DECHfor examples using %DEC.