Re: maximum digits for NUMERIC

From: Gianni Ciolli <gianni(dot)ciolli(at)2ndquadrant(dot)it>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: maximum digits for NUMERIC
Date: 2011-03-11 15:16:52
Message-ID: 20110311151652.GC4661@albo.gi.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 11, 2011 at 09:38:03AM -0500, Tom Lane wrote:
> Gianni Ciolli <gianni(dot)ciolli(at)2ndquadrant(dot)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(dot)ciolli(at)2ndquadrant(dot)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).

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-03-11 15:17:32 Re: why is max standby delay only 35 minutes?
Previous Message Tom Lane 2011-03-11 14:38:03 Re: maximum digits for NUMERIC