From: Tom Lane <tgl@sss.pgh.pa.us>
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
Cc: 'pgsql-admin@hub.org' <pgsql-admin@hub.org>
Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Subject: Re: [SQL] float4
Date: Mon, 28 Jun 1999 19:32:07 -0400
Message-ID: <18537.930612727@sss.pgh.pa.us> (raw)
In-Reply-To: <01BEC17C.FE853200.jt-kirkpatrick@mpsllc.com>
JT Kirkpatrick <jt-kirkpatrick@mpsllc.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, jt-kirkpatrick@mpsllc.com, pgsql-admin@hub.org, pgsql-sql@hub.org
Subject: Re: [SQL] float4
In-Reply-To: <18537.930612727@sss.pgh.pa.us>
References: <01BEC17C.FE853200.jt-kirkpatrick@mpsllc.com> <18537.930612727@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox