From eab5d643b2b2ec7cbf2b524b10b964aa6f273f54 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 17 Jun 2003 23:12:36 +0000 Subject: [PATCH] Make FLOAT(p) measure the precision p in bits, not decimal digits, to match the SQL standard. Document FLOAT and FLOAT(p) notations in datatype.sgml. Per recent pghackers discussion. --- doc/src/sgml/datatype.sgml | 41 +++++++++++++++++++++++++++++++++----- doc/src/sgml/release.sgml | 3 ++- src/backend/parser/gram.y | 12 +++++------ 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index d96c14e060..05faaa422f 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,5 +1,5 @@ @@ -607,16 +607,47 @@ NUMERIC - Normally, the real type has a range of at least - -1E+37 to +1E+37 with a precision of at least 6 decimal digits. The - double precision type normally has a range of around - -1E+308 to +1E+308 with a precision of at least 15 digits. Values that + On most platforms, the real type has a range of at least + 1E-37 to 1E+37 with a precision of at least 6 decimal digits. The + double precision type typically has a range of around + 1E-307 to 1E+308 with a precision of at least 15 digits. Values that are too large or too small will cause an error. Rounding may take place if the precision of an input number is too high. Numbers too close to zero that are not representable as distinct from zero will cause an underflow error. + + PostgreSQL also supports the SQL-standard + notations float and + float(p) for specifying + inexact numeric types. Here, p specifies + the minimum acceptable precision in binary digits. + PostgreSQL accepts + float(1) to float(24) as selecting the + real type, while + float(25) to float(53) select + double precision. Values of p + outside the allowed range draw an error. + float with no precision specified is taken to mean + double precision. + + + + + Prior to PostgreSQL 7.4, the precision in + float(p) was taken to mean + so many decimal digits. This has been corrected to match the SQL + standard, which specifies that the precision is measured in binary + digits. The assumption that real and + double precision have exactly 24 and 53 bits in the + mantissa respectively is correct for IEEE-standard floating point + implementations. On non-IEEE platforms it may be off a little, but + for simplicity the same ranges of p are used + on all platforms. + + + diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index db59de76f6..382029b81f 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -1,5 +1,5 @@ @@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without worries about funny characters. -->