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 0C4AC5E46EE for ; Tue, 31 Aug 2004 11:18:11 -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 23477-08 for ; Tue, 31 Aug 2004 14:17:59 +0000 (GMT) Received: from smtp109.mail.sc5.yahoo.com (smtp109.mail.sc5.yahoo.com [66.163.170.7]) by svr1.postgresql.org (Postfix) with SMTP id 6A9775E46CE for ; Tue, 31 Aug 2004 11:18:02 -0300 (ADT) Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 with login) by smtp109.mail.sc5.yahoo.com with SMTP; 31 Aug 2004 14:18:05 -0000 Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) (authenticated bits=0) by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id i7VEI3T7071860; Tue, 31 Aug 2004 10:18:04 -0400 (EDT) (envelope-from JanWieck@Yahoo.com) Message-ID: <41348898.1070107@Yahoo.com> Date: Tue, 31 Aug 2004 10:18:00 -0400 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rajesh Kumar Mallah Cc: Michael Glaesemann , pgsql-sql@postgresql.org Subject: Re: Arbitrary precision arithmatic with pgsql References: <41346727.8080901@trade-india.com> <1089006C-FB4B-11D8-A2A0-000A95C88220@myrealbox.com> <41347A0F.70300@trade-india.com> In-Reply-To: <41347A0F.70300@trade-india.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.6 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL X-Spam-Level: * X-Archive-Number: 200408/343 X-Sequence-Number: 18840 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. >> >> >> >> 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. >> >> > > > 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 #