From: Rajesh Kumar Mallah <mallah@trade-india.com>
To: Michael Glaesemann <grzm@myrealbox.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Arbitrary precision arithmatic with pgsql
Date: Tue, 31 Aug 2004 18:07:33 +0530
Message-ID: <4134710D.70501@trade-india.com> (raw)
In-Reply-To: <BD1D3E59-FB47-11D8-A2A0-000A95C88220@myrealbox.com>
References: <41346727.8080901@trade-india.com>
<BD1D3E59-FB47-11D8-A2A0-000A95C88220@myrealbox.com>
Michael Glaesemann wrote:
>
> 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.
Looks like the power operation of numeric ie, numeric ^ numeric already
exists
but it returns a double precision and the accuracy is getting lost. Shud
numeric
^ numeric not be returning numeric instead?
Regds
mallah.
tradein_clients=# CREATE TABLE t_a as SELECT 1::numeric ^ 1::numeric
as col;
SELECT
tradein_clients=# \d t_a
Table "public.t_a"
+--------+------------------+-----------+
| Column | Type | Modifiers |
+--------+------------------+-----------+
| col | double precision | |
+--------+------------------+-----------+
>
>> 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
>
>
> !DSPAM:41346ebe315451222497446!
>
>
--
regds
Mallah.
Rajesh Kumar Mallah
+---------------------------------------------------+
| Tradeindia.com (3,11,246) Registered Users |
| Indias' Leading B2B eMarketPlace |
| http://www.tradeindia.com/ |
+---------------------------------------------------+
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mallah@trade-india.com, grzm@myrealbox.com
Subject: Re: Arbitrary precision arithmatic with pgsql
In-Reply-To: <4134710D.70501@trade-india.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox