Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

pgsql-general by date

Next:From: Jaime CasanovaDate: 2005-12-02 19:02:27
Subject: Re: Slow COUNT
Previous:From: Bruce MomjianDate: 2005-12-02 18:42:40
Subject: Re: Numeric 508 datatype

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group