Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id D56EA9FB4B4 for ; Tue, 17 Apr 2007 16:04:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 05862-07 for ; Tue, 17 Apr 2007 16:04:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 612D59FB51F for ; Tue, 17 Apr 2007 16:04:50 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1Hdsyv-0003aC-13 for pgsql-sql@postgresql.org; Tue, 17 Apr 2007 15:04:49 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 8EC434050; Tue, 17 Apr 2007 15:04:43 -0400 (EDT) Date: Tue, 17 Apr 2007 15:04:43 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Floating point type to store numbers Message-ID: <20070417190443.GA9094@phlogiston.dyndns.org> References: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/151 X-Sequence-Number: 28151 On Tue, Apr 17, 2007 at 02:53:54PM -0400, Radhika Sambamurti wrote: > that hold money fields and rates from varchar to float. I do not want to > convert to numeric because numeric is a special string type. I think you should reconsider. The _only_ correct storage for your money data (i.e. if you want to do calculations on them) is numeric. Float is always wrong, in every application, for this sort of work. Obviously, you can store the values as text, but if you want to do calculations, you'll need to cast (in which case you're casting to numeric, I hope, or you could lose precision). > The question is: how accurate is floating point numbers in Postgres. We As accurate as they are in the underlying C implementation, which is to say "not accurate enough for financial data". A -- Andrew Sullivan | ajs@crankycanuck.ca A certain description of men are for getting out of debt, yet are against all taxes for raising money to pay it off. --Alexander Hamilton