X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CBD315E46C2 for ; Tue, 31 Aug 2004 12:04:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43337-07 for ; Tue, 31 Aug 2004 15:04:54 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 016805E46F9 for ; Tue, 31 Aug 2004 12:04:45 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7VF4qYE029457; Tue, 31 Aug 2004 11:04:52 -0400 (EDT) To: Jan Wieck Cc: Rajesh Kumar Mallah , Michael Glaesemann , pgsql-sql@postgresql.org Subject: Re: Arbitrary precision arithmatic with pgsql In-reply-to: <41348898.1070107@Yahoo.com> References: <41346727.8080901@trade-india.com> <1089006C-FB4B-11D8-A2A0-000A95C88220@myrealbox.com> <41347A0F.70300@trade-india.com> <41348898.1070107@Yahoo.com> Comments: In-reply-to Jan Wieck message dated "Tue, 31 Aug 2004 10:18:00 -0400" Date: Tue, 31 Aug 2004 11:04:52 -0400 Message-ID: <29456.1093964692@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/345 X-Sequence-Number: 18842 Jan Wieck 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