From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jan Wieck <JanWieck@Yahoo.com>
Cc: 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 11:04:52 -0400
Message-ID: <29456.1093964692@sss.pgh.pa.us> (raw)
In-Reply-To: <41348898.1070107@Yahoo.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>
<41348898.1070107@Yahoo.com>
Jan Wieck <JanWieck@Yahoo.com> writes:
> I agree that doing
> select 2::numeric ^ 100;
> should emit some sort of a warning.
I do not. The conversion of 2::numeric to float is exact, so AFAICS
the only way to do that would be to make *every* coercion of numeric to
float emit a warning. This is not a reasonable response to the fact
that Rajesh is unaware of the set of available operators. Moreover
it would essentially break float constants (since "2.0" starts life
as numeric and is only cast to float when the context demands).
I'd be in favor of adding a numeric^numeric operator to ease access to
the existing pow() code, but I'm not sure this makes the issue go away
entirely. It looks like "select 2 ^ 100" would still default to being
a float operation.
regression=# create operator ^ (procedure=pow, leftarg=numeric, rightarg=numeric);
CREATE OPERATOR
regression=# select 2::numeric ^ 100;
?column?
--------------------------------------------------
1267650600228229401496703205376.0000000000000000
(1 row)
regression=# select 2 ^ 100;
?column?
----------------------
1.26765060022823e+30
(1 row)
regression=# select 2.0 ^ 100;
?column?
--------------------------------------------------
1267650600228229401496703205376.0000000000000000
(1 row)
regards, tom lane
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: tgl@sss.pgh.pa.us, JanWieck@Yahoo.com, mallah@trade-india.com, grzm@myrealbox.com
Subject: Re: Arbitrary precision arithmatic with pgsql
In-Reply-To: <29456.1093964692@sss.pgh.pa.us>
* 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