Re: Numeric 508 datatype - Mailing list pgsql-patches

From Tom Lane
Subject Re: Numeric 508 datatype
Date
Msg-id 4533.1133549673@sss.pgh.pa.us
Whole thread Raw
In response to Re: Numeric 508 datatype  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Numeric 508 datatype
List pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Sorry, I am confused.  If our computational range is that high, why does
> SELECT factorial(4000) and SELECT factorial(6000) produce the same
> number of digits on my screen.

Are you counting correctly?

regression=# select log(factorial(4000));
          log
------------------------
 12673.2621666764869773
(1 row)

regression=# select log(factorial(6000));
        log
--------------------
 20065.428782473590
(1 row)

regression=# select factorial(4000)
regression-# \g z4000
regression=# select factorial(6000)
regression-# \g z6000
regression=# \q
$ wc z4000 z6000
5 5 38039 z4000
5 5 60215 z6000

The actual representation limit at the moment (with int16 weights in the
storable format) is 10^128K, as you can soon prove with pow():

regression=# select pow(10::numeric, 131071);
    << lots o zeroes >>
regression=# select pow(10::numeric, 131072);
ERROR:  value overflows numeric format

I don't recall what factorial that might correspond to, but it's
considerably above 6000.

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Should libedit be preferred to libreadline?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: [HACKERS] Should libedit be preferred to libreadline?