pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: Mark Stosberg <mark@summersault.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: function to format floats as money?
Date: Tue, 17 Apr 2001 12:41:04 -0500
Message-ID: <20010417124104.C17425@rice.edu> (raw)
In-Reply-To: <3ADC61E0.93E7865D@summersault.com>
References: <Pine.LNX.4.30.0104171724230.762-100000@peter.localdomain>
	<3ADC61E0.93E7865D@summersault.com>

On Tue, Apr 17, 2001 at 10:31:49AM -0500, Mark Stosberg wrote:
> Peter Eisentraut wrote:
> > 
> > Mark Stosberg writes:
> > 
> > >   I'm curious to know if there is a function available in Postgres 7.0.3
> > > (or 7.1) that will format a float style number as "money". I understand
> > > that the money type is going away in the future, so using a float type
> > > that is sometimes formatted like money seems like a good alternative. So
> > > ideally, I'm looking for a solution that won't go away when the money type
> > > does. :) Thanks!
> > 
> > to_char() for formatting.
> > 
> > numeric for storage.
> > 
> > Using floats for monetary amounts is not only an extremely bad idea
> > because of the inexactness of storage and arithmetic, it might even be
> > illegal if you're using it for official purposes.
> 
> Thanks Peter.
> 
>   So  if the money type is going away, and floats can be illegal, whats
> the best way to store money? 

Why, in the bank, or under your mattress, depending on your level of
paranoia, of course. But seriously, numeric(10,2) (or whatever precision
and scale is correct for your application) is the standard answer.

 Ross



view thread (7+ messages)  latest in thread

Message-ID: <20010417124104.C17425@rice.edu>
Permalink:  ../20010417124104.C17425@rice.edu/
Also on:    postgresql.org/message-id/20010417124104.C17425@rice.edu

 · 

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 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: reedstrm@rice.edu, mark@summersault.com
  Subject: Re: function to format floats as money?
  In-Reply-To: <20010417124104.C17425@rice.edu>
  References: <Pine.LNX.4.30.0104171724230.762-100000@peter.localdomain> <3ADC61E0.93E7865D@summersault.com> <20010417124104.C17425@rice.edu>

* 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