From: Jan Wieck <JanWieck@Yahoo.com>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
Cc: Michael Glaesemann <grzm@myrealbox.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Arbitrary precision arithmatic with pgsql
Date: Tue, 31 Aug 2004 10:18:00 -0400
Message-ID: <41348898.1070107@Yahoo.com> (raw)
In-Reply-To: <41347A0F.70300@trade-india.com>
References: <41346727.8080901@trade-india.com>
<BD1D3E59-FB47-11D8-A2A0-000A95C88220@myrealbox.com>
<1089006C-FB4B-11D8-A2A0-000A95C88220@myrealbox.com>
<41347A0F.70300@trade-india.com>
On 8/31/2004 9:15 AM, Rajesh Kumar Mallah wrote:
> Michael Glaesemann wrote:
>
>>
>> On Aug 31, 2004, at 9:17 PM, Michael Glaesemann wrote:
>>
>>> What you need is a power operation for numeric, which I think you'd
>>> have to write yourself,
>>
>>
>> Looking a little closer, there is a pow() function that takes two
>> numeric arguments and returns numeric.
>>
>> <http://www.postgresql.org/docs/current/static/functions-math.html;
>>
>> test=# select pow(2::numeric,100::numeric);
>> pow
>> --------------------------------------------------
>> 1267650600228229401496703205376.0000000000000000
>> (1 row)
>>
>> Sorry for the misinformation.
>>
>> If you'd like, I think you can overload the ^ operator to work on
>> numeric as well if you don't want to use pow(). See the following page
>> for more information.
>>
>> <http://www.postgresql.org/docs/current/static/sql-createoperator.html;
>
>
> Yep thats cool. Thanks for the research!
>
> but i still wonder if a warning or info message were
> appropriate at some stage so that people do not confuse it
> with sielent loss of accuracy . I know this example is *not* a
> case of where postgresql is truncating data at the insert level
> (like mysql does) but at the calculation level.
I agree that doing
select 2::numeric ^ 100;
should emit some sort of a warning. Because what happens here is that
the numeric value is degraded to a float8 in order to use the operator.
I don't think that
select 2 ^ 100;
should emit the same warning.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.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: JanWieck@Yahoo.com, mallah@trade-india.com, grzm@myrealbox.com
Subject: Re: Arbitrary precision arithmatic with pgsql
In-Reply-To: <41348898.1070107@Yahoo.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