Re: numeric precision when raising one numeric to

From: Claudio Succa <claudio(dot)succa(dot)ml(at)pertel(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: numeric precision when raising one numeric to
Date: 2005-05-20 17:19:50
Message-ID: 200505201919.51164.claudio.succa.ml@pertel.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

17:28, venerdì 20 maggio 2005 - Tom Lane scrive:
|> Has anyone bothered to actually look into the code?
|>
|> regression=# select power(2::numeric,1000);
|>
|> power
|> --------------------------------------------------------------------------
|>---------------------------------------------------------------------------
|>---------------------------------------------------------------------------
|>---------------------------------------------------------------------------
|>----------------------
|> 10715086071862673209484250490600018105614048117055336074437503883703510511
|>249361224931983788156958581275946729175531468251871452856923140435984577574
|>698574803934567774824230985421074605062371141877954182153046474983581941267
|>398767559165543946077062914571196477686542167660429831652624386837205668069
|>376.0000000000000000 (1 row)

Just for curiosity.

With PostgreSQL 7.4.7 on Linux/Debian platform I had a different result so I
made the subtraction of your figure:

psql -h s1 -d rapp-test -c "select power(2::numeric,1000) -
10715086071862673209484250490600018105614048117055336074437503883703510511
249361224931983788156958581275946729175531468251871452856923140435984577574
698574803934567774824230985421074605062371141877954182153046474983581941267
398767559165543946077062914571196477686542167660429831652624386837205668069
376.0000000000000000"

the difference seems to be more than some decimals:

?column?
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------------------
-12930966888749171763979711252782126059745074561323490485649902084788364060
8509196350026606450797474300013235449638255271591657519292725441403643666323
4303290336621701615570133781468903988395214925377190448567739467132002913627
731843776737159303888471.0573553374557744
(1 row)

Why I did not get some error message? And how can I be aware of exeeding the
system capacity?

(what am I wrong about?)

Claudio

--
Claudio Succa
PERTEL - Torino - Italy
+39-011-437.4141
http://www.pertel.it
http://www.uniassist.it
http://www.progettocapolinea36.it

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2005-05-20 17:22:33 Re: numeric precision when raising one numeric to another.
Previous Message Robert Treat 2005-05-20 17:17:50 Re: How can I write trigger on a columns insert/update?