Re: maximum digits for NUMERIC - Mailing list pgsql-hackers

From Gianni Ciolli
Subject Re: maximum digits for NUMERIC
Date
Msg-id 20110311151652.GC4661@albo.gi.lan
Whole thread Raw
In response to Re: maximum digits for NUMERIC  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Mar 11, 2011 at 09:38:03AM -0500, Tom Lane wrote:
> Gianni Ciolli <gianni.ciolli@2ndquadrant.it> writes:
> > maybe we should change the "1000 digits" here:
> 
> >   http://developer.postgresql.org/pgdocs/postgres/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL
> 
> > because ISTM that up to 2^17 digits are supported
> 
> This is incorrect.  (You're confusing the number of stored digits
> with the location of the decimal point.)

My understanding of the documentation is that precision is defined as
"the total count of significant digits in the whole number" while the
location of the decimal point can be determined by the scale, which is
defined as "the count of decimal digits in the fractional part, to the
right of the decimal point".

The documentation I mentioned previously starts with
 "The type numeric can store numbers with up to 1000 digits of precision and perform calculations exactly."

and I was able to store a base 10 integers with up to 2^17 digits in a
NUMERIC; so I still believe that the documentation is incorrect in
saying that (by my understanding of the definition of significant
digits in an exact integer).

If there is a limit of 1000 on the number of fractional digits to the
right of the decimal points, then we should change that wording
(unfortunately I won't be able to run this test before UTC+0 evening).

Best regards,
Dr. Gianni Ciolli - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
gianni.ciolli@2ndquadrant.it | www.2ndquadrant.it

p.s. my small investigation started from having read the    documentation, having incorrectly believed that NUMERIC
would   have rejected integers greater than 10^1000, and finding    experimentally that the threshold is about
10^(2^17)(all with    9.0).
 



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: maximum digits for NUMERIC
Next
From: Bruce Momjian
Date:
Subject: Re: why is max standby delay only 35 minutes?