Re: Floating point type to store numbers

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Floating point type to store numbers
Date: 2007-04-17 19:04:43
Message-ID: 20070417190443.GA9094@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)crankycanuck(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Milen A. Radev 2007-04-17 19:10:40 Re: Floating point type to store numbers
Previous Message Radhika Sambamurti 2007-04-17 18:53:54 Floating point type to store numbers