FLOAT
type
Applies to: Databricks SQL Databricks Runtime
Represents 4-byte single-precision floating point numbers.
Syntax
{ FLOAT | REAL }
Limits
The range of numbers is:
- -∞ (negative infinity)
- -3.402E+38 to -1.175E-37
- 0
- +1.175E-37 to +3.402E+38
- +∞ (positive infinity)
- NaN (not a number)
Literals
decimal_digits [ exponent ] F
| [ + | - ] digit [ ... ] [ exponent ] F
decimal_digits:
[ + | - ] { digit [ ... ] . [ digit [ ... ] ]
| . digit [ ... ] }
exponent:
E [ + | - ] digit [ ... ]
digit
: Any numeral from 0 to 9.
The F
postfix and E
exponent are case insensitive.
Notes
FLOAT is a base-2 numeric type. When given a literal which is base-10 the representation may not be exact. Use DECIMAL type to accurately represent fractional or large base-10 numbers.
Examples
> SELECT +1F;
1.0
> SELECT 5E10F;
5E10
> SELECT 5.3E10F;
5.3E10
> SELECT -.1F;
-0.1
> SELECT 2.F;
2.0
> SELECT -5555555555555555.1F
-5.5555558E15
> SELECT CAST(6.1 AS FLOAT)
6.1