Re: How useful is the money datatype?

Поиск
Список
Период
Сортировка
Искать
От
Greg Stark
Тема
Re: How useful is the money datatype?
Дата
Msg-id
407d949e0910030905o67a45d78n4ddf0d8d07bd6bdd@mail.gmail.com
Ответ на
Список
Дерево обсуждения
How useful is the money datatype? Thom Brown <thombrown@gmail.com>
Re: How useful is the money datatype? Peter Eisentraut <peter_e@gmx.net>
Re: How useful is the money datatype? Raymond O'Donnell <rod@iol.ie>
Re: How useful is the money datatype? Thom Brown <thombrown@gmail.com>
Re: How useful is the money datatype? Filip Rembiałkowski <plk.zuber@gmail.com>
Re: How useful is the money datatype? Peter Geoghegan <peter.geoghegan86@gmail.com>
Re: How useful is the money datatype? Grzegorz Jaśkiewicz <gryzman@gmail.com>
Re: How useful is the money datatype? Greg Stark <gsstark@mit.edu>
Re: How useful is the money datatype? Raymond O'Donnell <rod@iol.ie>
Re: How useful is the money datatype? Sam Mason <sam@samason.me.uk>
Re: How useful is the money datatype? Merlin Moncure <mmoncure@gmail.com>
Re: How useful is the money datatype? Sam Mason <sam@samason.me.uk>
Re: How useful is the money datatype? "V S P" <pgsql-general@postgresql.org>
Re: How useful is the money datatype? Sam Mason <sam@samason.me.uk>
Re: How useful is the money datatype? Craig Ringer <craig@postnewspapers.com.au>
Re: How useful is the money datatype? Rich Shepard <rshepard@appl-ecosys.com>
Re: How useful is the money datatype? Sam Mason <sam@samason.me.uk>
Re: How useful is the money datatype? justin <justin@emproshunts.com>
Re: How useful is the money datatype? Guy Rouillier <guyr-ml1@burntmail.com>
Re: How useful is the money datatype? Christophe Pettus <xof@thebuild.com>
Re: How useful is the money datatype? Guy Rouillier <guyr-ml1@burntmail.com>
Re: How useful is the money datatype? Bruce Momjian <bruce@momjian.us>
Re: How useful is the money datatype? Guy Rouillier <guyr-ml1@burntmail.com>
Re: How useful is the money datatype? John R Pierce <pierce@hogranch.com>
Re: How useful is the money datatype? Christophe Pettus <xof@thebuild.com>
Re: How useful is the money datatype? Sam Mason <sam@samason.me.uk>
Re: How useful is the money datatype? Peter Geoghegan <peter.geoghegan86@gmail.com>
Re: How useful is the money datatype? Thom Brown <thombrown@gmail.com>
2009/10/3 Grzegorz Jaśkiewicz :
> depending on the countries, etc - keep currencies in 10.4 , or you can
> compromise to 10.3 , otherwise you might run into problems with rounding,
> etc.

Keeping more digits of precision than the application actually can use
is more likely to *cause* problems with rounding than solve them.

For example, if you calculate interest on a balance (using floating
point arithmetic) and then round it to $10.001 and store that in the
balance your application will tell the user and your accounting
department that they have $10 and their account. But if you do this
ten times they'll mysteriously have an extra cent that the accounting
department will not be able to account for.

To avoid problems like this you must store precisely as many digits as
the application requires. No more and no less. Intermediate
calculations can be done with more precision or floating point
arithmetic but you have to round or truncate before reporting the
results and then store precisely the value you reported.

-- 
greg
В списке pgsql-general по дате отправления
От: Merlin Moncure
Дата:
От: Martin Gainty
Дата:
FAQ