Re: Money data type in PostgreSQL?
От | Craig O'Shannessy |
---|---|
Тема | Re: Money data type in PostgreSQL? |
Дата | |
Msg-id | Pine.LNX.4.44.0312051603520.8177-100000@mail.undercoverwear.com.au обсуждение исходный текст |
Ответ на | Re: Money data type in PostgreSQL? (Jan Wieck <JanWieck@Yahoo.com>) |
Список | 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 по дате отправления: