Re: Numeric 508 datatype

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Numeric 508 datatype
Date: 2005-12-02 18:54:33
Message-ID: 4533.1133549673@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jaime Casanova 2005-12-02 19:02:27 Re: Slow COUNT
Previous Message Bruce Momjian 2005-12-02 18:42:40 Re: Numeric 508 datatype

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2005-12-02 19:01:05 Re: [HACKERS] Should libedit be preferred to libreadline?
Previous Message Bruce Momjian 2005-12-02 18:52:07 Re: [HACKERS] Should libedit be preferred to libreadline?

Browse pgsql-patches by date

  From Date Subject
Next Message Joshua D. Drake 2005-12-02 19:01:05 Re: [HACKERS] Should libedit be preferred to libreadline?
Previous Message Bruce Momjian 2005-12-02 18:52:07 Re: [HACKERS] Should libedit be preferred to libreadline?