Appearance
DOUBLE PRECISION
REAL and DOUBLE PRECISION are floating-point data types. These data types store numeric values with variable precision. Some values may be stored as approximations; you may see slight discrepancies between a value that is loaded and value that is returned. The DECIMAL data type provides more exact results.
The DOUBLE PRECISION data type stores 64-bit floating-point values (8 bytes). The precision of a DOUBLE PRECISION column is 15 digits.
FLOAT and FLOAT8 and are valid synonyms for DOUBLE PRECISION.
Note: FLOAT8
and FLOAT(8)
are not synonyms. Yellowbrick permits the float(p)
syntax but will promote it to the next floating-point number into which it will fit. This behavior is different than PostgreSQL.
Leading zeroes and whitespace characters are allowed. Trailing whitespace characters are also allowed.
Note: Yellowbrick supports NaN
(not a number) and Infinity
as floating-point values. The system can store and operate on these values.
- Conversion of
NaN
,Infinity
,+inf
, and-inf
to string types produces the appropriate string. - DECIMAL and INTEGER types do not support these values for storage or conversion.
- When
NaN
is compared to a number, the result of the comparison is alwaysfalse
. - When an ORDER BY clause sorts
NaN
with numbers,NaN
always sorts as greater than those numbers.
The following example demonstrates the values that you can load into a DOUBLE PRECISION column. Note that floating-point values with excess digits on the right side of the decimal point are rounded. Values with excess digits on the left side of the decimal point are converted to scientific notation; these values are not rejected.
premdb=# create table floattest(c1 float);
CREATE TABLE
premdb=# \d floattest
Table "public.floattest"
Column | Type | Modifiers
--------+------------------+-----------
c1 | double precision |
Distribution: Hash (c1)
premdb=# insert into floattest values(1000000000000.123);
INSERT 0 1
premdb=# select * from floattest;
c1
------------------
1000000000000.12
(1 row)
premdb=# insert into floattest values(1000000000000000);
INSERT 0 1
premdb=# select * from floattest;
c1
------------------
1000000000000.12
1e+15
(2 rows)
Parent topic:SQL Data Types