Home > Archive > PostgreSQL Discussion > May 2005 > Re: numeric precision when raising one numeric to









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: numeric precision when raising one numeric to
Tom Lane

2005-05-20, 11:23 am

Has anyone bothered to actually look into the code?

regression=# select power(2::numeric,100
0);
power
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------
10715086071862673209
48425049060001810561
40481170553360744375
03883703510511249361
22493198378815695858
12759467291755314682
51871452856923140435
98457757469857480393
45677748242309854210
74605062371141877954
18215304647498358194
12673987675591655439
46077062914571
19647768654216766042
98316526243868372056
68069376.0000000000000000
(1 row)

AFAICT the only thing missing is a pg_operator entry linked to the
function.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Claudio Succa

2005-05-20, 1:23 pm

17:28, venerd́ 20 maggio 2005 - Tom Lane scrive:
|> Has anyone bothered to actually look into the code?
|>
|> regression=# select power(2::numeric,100
0);
|>
|> power
|> --------------------------------------------------------------------------
|>---------------------------------------------------------------------------
|>---------------------------------------------------------------------------
|>---------------------------------------------------------------------------
|>----------------------
|> 10715086071862673209
48425049060001810561
40481170553360744375
03883703510511
|> 24936122493198378815
69585812759467291755
31468251871452856923
140435984577574
|> 69857480393456777482
42309854210746050623
71141877954182153046
474983581941267
|> 39876755916554394607
70629145711964776865
42167660429831652624
386837205668069
|>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,100
0) -
10715086071862673209
48425049060001810561
40481170553360744375
03883703510511
24936122493198378815
69585812759467291755
31468251871452856923
140435984577574
69857480393456777482
42309854210746050623
71141877954182153046
474983581941267
39876755916554394607
70629145711964776865
42167660429831652624
386837205668069
376.0000000000000000"

the difference seems to be more than some decimals:

?column?
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------------------
- 12930966888749171763
97971125278212605974
50745613234904856499
02084788364060
85091963500266064507
97474300013235449638
25527159165751929272
5441403643666323
43032903366217016155
70133781468903988395
21492537719044856773
9467132002913627
73184377673715930388
8471.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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Tom Lane

2005-05-20, 8:24 pm

Claudio Succa <claudio.succa.ml@pertel.it> writes:
> 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,100
0) -


I don't know what you're getting there, but there is no power() function
at all in a standard 7.4 installation. Possibly you have a homebrew
function that uses the floating-point dpow() code?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Bruce Momjian

2005-05-30, 8:23 pm

Tom Lane wrote:
> Has anyone bothered to actually look into the code?
>
> regression=# select power(2::numeric,100
0);
> power
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------
> 10715086071862673209
48425049060001810561
40481170553360744375
03883703510511249361
22493198378815695858
12759467291755314682
51871452856923140435
98457757469857480393
45677748242309854210
74605062371141877954
18215304647498358194
12673987675591655439
460770629145

71196477686542167660
42983165262438683720
5668069376. 0000000000000000[col
or=darkred]
> (1 row)
>
> AFAICT the only thing missing is a pg_operator entry linked to the
> function.[/color]

Patch to add NUMERIC ^ NUMERIC operator added and applied. Catalog
version bumped. This will be in 8.1. FYI, this already does the right
thing (no rounding) if the second argument is an integal value, see
power_var().

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com