DOUBLE PRECISION (8-byte double-precision float)
Last updated: 2026-11-04
DOUBLE PRECISION (8-byte double-precision float)
DOUBLE PRECISION matches C's double: 8 bytes with 53 mantissa bits, about 15 to 16 decimal digits of significance, and it is PostgreSQL's default floating-point type. Written as FLOAT(p), p ranges from 1 to 53: p ≤ 24 maps to REAL and p ≥ 25 maps to DOUBLE PRECISION. It is far more precise than REAL, yet it remains binary floating point and still cannot represent 0.1 exactly.
| Kind | type |
|---|---|
| Example Language | SQL |
📝 Syntax
DOUBLE PRECISION | FLOAT8 | FLOAT
FLOAT(p) —— p from 1 to 53: p ≤ 24 means REAL, p ≥ 25 means DOUBLE PRECISION
Returns:Holds an 8-byte double-precision float. Decimal values are converted to their nearest binary approximation, so summing rows can surface tails such as 0.30000000000000004; compare with a tolerance rather than equality.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
id | ratio | col_type | exact_equal
----+--------------------+------------------+-------------
1 | 0.1 | double precision | f
2 | 0.3333333333333333 | double precision | f
📌 Key Points
- 0.1::double precision + 0.2::double precision produces 0.30000000000000004, which is not equal to 0.3::double precision — the classic demonstration of floating-point error.
- 1::double precision / 3::double precision yields 0.3333333333333333, about 16 significant digits, still an approximation rather than an exact fraction.
- Floating-point types keep no trailing zeros: 10.00::double precision prints as 10. Only NUMERIC(p, s) preserves the declared scale, keeping a form like 10.00.