Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A5BA19FB7F7 for ; Tue, 17 Apr 2007 17:33:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 07012-06-4 for ; Tue, 17 Apr 2007 17:33:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from rootabega.88thstreet.com (dsl254-071-237.nyc1.dsl.speakeasy.net [216.254.71.237]) by postgresql.org (Postfix) with ESMTP id E12439FB7BF for ; Tue, 17 Apr 2007 17:33:37 -0300 (ADT) Received: from www.88thstreet.com (localhost [IPv6:::1]) by rootabega.88thstreet.com (8.13.3/8.13.3) with ESMTP id l3HKXV29005808; Tue, 17 Apr 2007 16:33:33 -0400 (EDT) Received: from 63.118.86.10 (SquirrelMail authenticated user radhika) by www.88thstreet.com with HTTP; Tue, 17 Apr 2007 16:33:33 -0400 (EDT) Message-ID: <19968.63.118.86.10.1176842013.squirrel@www.88thstreet.com> In-Reply-To: <20070417190443.GA9094@phlogiston.dyndns.org> References: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com> <20070417190443.GA9094@phlogiston.dyndns.org> Date: Tue, 17 Apr 2007 16:33:33 -0400 (EDT) Subject: Re: Floating point type to store numbers From: "Radhika Sambamurti" To: "Andrew Sullivan" Cc: pgsql-sql@postgresql.org Reply-To: radhika@88thstreet.com User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/155 X-Sequence-Number: 28155 Andrew, This has been quite helpful. My main concern is CPU cost. Thanks for the input. --Radhika > 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 > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > -- It is all a matter of perspective. You choose your view by choosing where to stand. Larry Wall ---