DOUBLE_PRECISION or DOUBLE
The DOUBLE_PRECISION and DOUBLE functions return a floating-point representation.
Numeric to Double
String to Double
The DOUBLE_PRECISION and DOUBLE functions return a 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 Double
- numeric-expression
- An expression that returns a value of any built-in numeric data
type.
The result is the same number that would occur if the expression were assigned to a double-precision floating-point column or variable.
String to Double
- string-expression
- An expression that returns a value that is a character-string
or graphic-string representation of a number.
If the argument is a string-expression, the result is the same number that would result from CAST( string-expression AS DOUBLE PRECISION). Leading and trailing blanks are eliminated and the resulting string must conform to the rules for forming a floating-point, decimal floating-point, integer, or decimal constant.
The single-byte character constant that must be used to delimit the decimal digits in string-expression from the whole part of the number is the default decimal point. For more information, see Decimal point.
The result of the function is a double-precision floating-point number. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
Note
Syntax alternatives: FLOAT is a synonym for DOUBLE_PRECISION and DOUBLE.
The CAST specification should be used to increase the portability of applications. For more information, see CAST specification.
Example
- Using the EMPLOYEE table, find the ratio of salary to commission
for employees whose commission is not zero. The columns involved (SALARY
and COMM) have DECIMAL data types. To eliminate the possibility of
out-of-range results, DOUBLE_PRECISION is applied to SALARY so that
the division is carried out in floating point:
SELECT EMPNO, DOUBLE_PRECISION(SALARY)/COMM FROM EMPLOYEE WHERE COMM > 0