From: | "Craig O'Shannessy" <craig(at)ucw(dot)com(dot)au> |
---|---|
To: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
Cc: | Graham Leggett <minfrin(at)sharp(dot)fm>, Christopher Browne <cbbrowne(at)acm(dot)org>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Money data type in PostgreSQL? |
Date: | 2003-12-05 05:05:48 |
Message-ID: | Pine.LNX.4.44.0312051603520.8177-100000@mail.undercoverwear.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2003-12-05 06:59:27 | Re: Groups vs. Roles |
Previous Message | Martijn van Oosterhout | 2003-12-05 04:23:19 | Re: How to obtain the real problem that avoids postgresql |