DOUBLE type

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Represents 8-byte double-precision floating point numbers.

Syntax

DOUBLE

Limits

The range of numbers is:

  • -∞ (negative infinity)
  • -1.79769E+308 to -2.225E-307
  • 0
  • +2.225E-307 to +1.79769E+308
  • +∞ (positive infinity)
  • NaN (not a number)

Literals

decimal_digits  { D | exponent [ D ] }
| digit [ ... ] { exponent [ D ] | [ exponent ] D }

decimal_digits:
[ + | - ] { digit [ ... ] . [ digit [ ... ] ]
            | . digit [ ... ] }

exponent:
E [ + | - ] digit [ ... ]

digit: Any numeral from 0 to 9.

The D postfix and E exponent are case insensitive.

Notes

DOUBLE 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 +1D;
  1.0

> SELECT 5E10;
  5E10

> SELECT 5.3E10;
  5.3E10

> SELECT -.1D;
  -0.1

> SELECT 2.D;
  2.0

> SELECT -5555555555555555.1D
-5.555555555555555E15

> SELECT CAST(-6.1 AS DOUBLE)
-6.1