Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA89964; Mon, 28 Jun 1999 19:33:22 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id TAA18539; Mon, 28 Jun 1999 19:32:08 -0400 (EDT) To: JT Kirkpatrick cc: "'pgsql-admin@hub.org'" , "'pgsql-sql@hub.org'" Subject: Re: [SQL] float4 In-reply-to: Your message of Mon, 28 Jun 1999 15:43:37 -0400 <01BEC17C.FE853200.jt-kirkpatrick@mpsllc.com> Date: Mon, 28 Jun 1999 19:32:07 -0400 Message-ID: <18537.930612727@sss.pgh.pa.us> From: Tom Lane JT Kirkpatrick writes: > 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!!! Yup, no surprise. float4 is good to about 6 decimal digits on most machines, and yours is evidently right in there with the pack. float8 is good to about 16 digits on most hardware, but I wouldn't really recommend it either if you need guaranteed-exact calculations. The money type in Postgres is a fairly crude hack that I can't recommend (it's basically an int4 representing cents, and will therefore poop out at 2^31 cents or about $20million). What you really want is the general "numeric" type added in Postgres 6.5 --- decimal representation with as many digit positions as you specify. It's a good deal slower for calculations than native floats, unfortunately, especially if you use a very wide numeric field. But calculations per-se are seldom the bottleneck for a database application... BTW, the current plan is to phase out the money type in favor of numeric in some future release. regards, tom lane