pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Floating point type to store numbers
Date: Tue, 17 Apr 2007 15:04:43 -0400
Message-ID: <20070417190443.GA9094@phlogiston.dyndns.org> (raw)
In-Reply-To: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com>
References: <4838.63.118.86.10.1176836034.squirrel@www.88thstreet.com>

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@crankycanuck.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



view thread (10+ messages)  latest in thread

Message-ID: <20070417190443.GA9094@phlogiston.dyndns.org>
Permalink:  ../20070417190443.GA9094@phlogiston.dyndns.org/
Also on:    postgresql.org/message-id/20070417190443.GA9094@phlogiston.dyndns.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ajs@crankycanuck.ca
  Subject: Re: Floating point type to store numbers
  In-Reply-To: <20070417190443.GA9094@phlogiston.dyndns.org>

* 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