Re: Money data type in PostgreSQL? - Mailing list pgsql-general

From Craig O'Shannessy
Subject Re: Money data type in PostgreSQL?
Date
Msg-id Pine.LNX.4.44.0312051603520.8177-100000@mail.undercoverwear.com.au
Whole thread Raw
In response to Re: Money data type in PostgreSQL?  (Jan Wieck <JanWieck@Yahoo.com>)
List pgsql-general
On Thu, 4 Dec 2003, Jan Wieck wrote:

> Graham Leggett wrote:
>
> > Christopher Browne wrote:
> >
> > What I have done is store the currency amounts as bigints, at the same
> > precision defined for the currency (ie cents for dollars, pence for
> > pounds, etc). This guarantees that you don't get any rounding errors
> > when storing the figures as a floating point type. When manipulating the
> > numbers, I use Java BigDecimals, which don't lose any precision either,
> > and convert back to bigints to store in the database.
>
> You won't get any rounding errors in NUMERIC either. What people should
> be concerned of is to find an arbitrary precision package for the
> frontend programming language they're using.
>

I agree, I use BigDecimal's in Java, and NUMERIC's in PostgreSQL, they
seem like a perfect match.  Floating point numbers are not suitable for
money in my opinion.


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: How to obtain the real problem that avoids postgresql
Next
From: Peter Eisentraut
Date:
Subject: Re: Groups vs. Roles