Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3Mtg-0006cX-Uw for pgsql-docs@arkaria.postgresql.org; Tue, 03 Apr 2018 14:26:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3Mtf-0001hZ-Sz for pgsql-docs@arkaria.postgresql.org; Tue, 03 Apr 2018 14:26:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3Mtf-0001hQ-Jx for pgsql-docs@lists.postgresql.org; Tue, 03 Apr 2018 14:26:51 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f3Mtc-0000yD-CM for pgsql-docs@lists.postgresql.org; Tue, 03 Apr 2018 14:26:50 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1f3MtZ-000659-IU; Tue, 03 Apr 2018 10:26:45 -0400 Date: Tue, 3 Apr 2018 10:26:45 -0400 From: Bruce Momjian To: scott.ure@caseware.com, pgsql-docs@lists.postgresql.org Subject: Re: float and float(p) missing from table 8.1 Message-ID: <20180403142645.GA6472@momjian.us> References: <152139310065.11961.13080741495660494967@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152139310065.11961.13080741495660494967@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 18, 2018 at 05:11:40PM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/10/static/datatype.html > Description: > > Maybe it is intentional, but the float and float(p) data types are missing > from table 8.1 > (https://www.postgresql.org/docs/10/static/datatype.html#DATATYPE-TABLE). > float4 and float8 are listed. Yes, I think it is intentional and is caused by the multiple aliases we have for numeric values. As you probably noted from the chart, the primary type name is 'real', which is ANSI specified, with an alias listed as float4. There is also double precision, with an alias of float8. float() is more complicated since it can be either real/float4 or double precision/float8 depending on the length, e.g.: CREATE TABLE test(x FLOAT(1), x2 FLOAT(25)); \d test Table "public.test" Column | Type | Collation | Nullable | Default --------+------------------+-----------+----------+--------- x | real | | | x2 | double precision | | | The switch from float4/float8 happens at binary digit length 25, and this is documented: https://www.postgresql.org/docs/10/static/datatype-numeric.html#DATATYPE-FLOAT 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. Adding float() to that chart seems like it would add too much complexity. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +