Re: Arbitrary precision arithmatic with pgsql - Mailing list pgsql-sql

From Michael Glaesemann
Subject Re: Arbitrary precision arithmatic with pgsql
Date
Msg-id BD1D3E59-FB47-11D8-A2A0-000A95C88220@myrealbox.com
Whole thread Raw
In response to Arbitrary precision arithmatic with pgsql  (Rajesh Kumar Mallah <mallah@trade-india.com>)
Responses Re: Arbitrary precision arithmatic with pgsql
Re: Arbitrary precision arithmatic with pgsql
List pgsql-sql
On Aug 31, 2004, at 8:55 PM, Rajesh Kumar Mallah wrote:

> The docs says that numeric type supports numbers upto
> any precision

<snip />

> However
>
> tradein_clients=# SELECT  cast(2^100 as numeric);

<snip />

> 1. Does the specs not require pgsql to print a warning or info ,
>   will it not be considered silient truncation of data.

AFAICS, the issue here is not the cast per se, but rather the power 
operation (2^100), which expects a double precision argument. This 
operation happens before the cast.

> 2. Is there any way to do such calculation using pgsql, i understand
>   bc is a better tool for it.

What you need is a power operation for numeric, which I think you'd 
have to write yourself, possibly leveraging one of the procedural 
languages (perhaps pl/perl) to access such an operation (as you 
yourself mentioned). I'm sure you could find an algorithm to port to 
PL/pgsql as well.

Hope this helps.

Michael Glaesemann
grzm myrealbox com



pgsql-sql by date:

Previous
From: sad
Date:
Subject: Re: casting BOOL to somthng
Next
From: Geoffrey
Date:
Subject: Re: casting BOOL to somthng