DECFLOAT
The DECFLOAT function returns a decimal floating-point representation of a number or a string representation of a number.
The DECFLOAT function returns a decimal floating-point representation of:
- A number
- A character or graphic string representation of a decimal number
- A character or graphic string representation of an integer
- A character or graphic string representation of a floating-point number
- A character or graphic string representation of a decimal floating-point number
Numeric to DECFLOAT
- numeric-expression
- An expression that returns a value of any built-in numeric data type.
- 34 or 16
- Specifies the number of digits of precision for the result. The default is 34.
The result is the same number that would occur if the first argument were assigned to a decimal floating-point column or variable.
String to DECFLOAT
- string-expression
- An expression that returns a value that is a character-string or graphic-string representation of a number. Leading and trailing blanks are eliminated and the resulting string folded to uppercase must conform to the rules for forming a floating-point, decimal floating-point, integer, or decimal constant.
- 34 or 16
- Specifies the number of digits of precision for the result. The default is 34.
- decimal-character
- Specifies the single-byte character constant that is used to delimit the decimal digits in string-expression from the whole part of the number. The character must be a period or comma. If decimal-character is not specified, the decimal point is the default decimal separator character. For more information, see Decimal point.
The result of the function is a DECFLOAT number with the specified (either implicitly or explicitly) number of digits of precision. If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
If necessary, the source is rounded to the precision of the target. See CURRENT DECFLOAT ROUNDING MODE for more information.
Note
Syntax alternatives: The CAST specification should be used to increase the portability of applications. For more information, see CAST specification.
Example
- Use the DECFLOAT function in order to force a DECFLOAT data type
to be returned in a select-list for the EDLEVEL column (data type
= SMALLINT) in the EMPLOYEE table. The EMPNO column should also appear
in the select-clause.
SELECT EMPNO, DECFLOAT(EDLEVEL,16) FROM EMPLOYEE