Received: from mail.rdc1.tx.home.com (imail@ha1.rdc1.tx.home.com [24.4.0.66]) by hub.org (8.9.3/8.9.3) with ESMTP id QAA65010; Mon, 28 Jun 1999 16:31:23 -0400 (EDT) (envelope-from garrett@bgb-consulting.com) Received: from bgb-consulting.com ([24.7.228.42]) by mail.rdc1.tx.home.com (InterMail v4.01.01.00 201-229-111) with ESMTP id <19990628203121.XGIK9450.mail.rdc1.tx.home.com@bgb-consulting.com>; Mon, 28 Jun 1999 13:31:21 -0700 Message-ID: <3777DB76.DEF7B64E@bgb-consulting.com> Date: Mon, 28 Jun 1999 15:30:46 -0500 From: Don Garrett Organization: BGB Consulting X-Mailer: Mozilla 4.61 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 CC: "'pgsql-admin@hub.org'" , "'pgsql-sql@hub.org'" Subject: Re: [ADMIN] float4 References: <01BEC17C.FE853200.jt-kirkpatrick@mpsllc.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit You shouldn't use a float at all for exact amounts. Floats handle arbitrary precision, but do it rounding off values somewhat. The way the round off works is based on the (base 2) internal representation and so it never quite seems to make sense in decimal. It's possible on some machines/float formats to have "if (1.0 + 1.0 = 2.0)" evaluate to false. When I first started programming, I did a very simple custom accounting package using floats.... and had to go back and rewrite all of it. You will do better to use integers (no rounding at all) and consider the contents to be the number of pennies involved, not dollars. JT Kirkpatrick wrote: > > we have a database (linux, 6.4.2, new odbc, connections from msaccess / > win98) -- access doesn't fully appreciate the monetary type in postgres, so > we made all monetary fields FLOAT4's. weird stuff -- or maybe not to you > -- we insert 23516.69 into a float4 field directly in psql, and then select > it, and it shows 23516.7. this is not good for a field used for MONEY!!! > what are the limitations of float4? should i have used float8? > > thanks for any help you can offer. . . > > jt -- Don Garrett dgarrett@acm.org BGB Consulting http://www.bgb-consulting.com/garrett