Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id C16249FB695 for ; Tue, 17 Apr 2007 16:10:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 18955-08 for ; Tue, 17 Apr 2007 16:10:53 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 7ADBD9FB7AD for ; Tue, 17 Apr 2007 16:10:55 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Hdt4b-0002S6-6F for pgsql-sql@postgresql.org; Tue, 17 Apr 2007 21:10:42 +0200 Received: from 85.187.136.11 ([85.187.136.11]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Apr 2007 21:10:41 +0200 Received: from milen by 85.187.136.11 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Apr 2007 21:10:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Milen A. Radev" Subject: Re: Floating point type to store numbers Date: Tue, 17 Apr 2007 22:10:40 +0300 Lines: 29 Message-ID: References: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 85.187.136.11 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) In-Reply-To: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/152 X-Sequence-Number: 28152 Radhika Sambamurti написа: > Hi, > I am currently using Postgresql to maintain an application which is used > for trading and back office operations. Currently our monetary fields are > stored in Varchar. I am finding a huge CPU utilization while converting > from varchar to float. I think for reasons unknown to me, we originally > stored $ amounts and rates in varchar. I am planning to convert our tables > 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. > > The question is: how accurate is floating point numbers in Postgres. We > are using 7.4 soon to be moving to 8.2. > I need the accuracy to about 6 decimal points. I have read that floating > points can convert to numbers in accurately. I believe the manual is quite clear on that one ( http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-FLOAT) : " - If you require exact storage and calculations (such as for monetary amounts), use the numeric type instead." So if you decide to use floats after this warning you are on your own. -- Milen A. Radev