Re: How useful is the money datatype?

From: Guy Rouillier <guyr-ml1(at)burntmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How useful is the money datatype?
Date: 2009-10-05 02:09:15
Message-ID: 4AC9554B.8040909@burntmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rich Shepard wrote:
> On Sun, 4 Oct 2009, Sam Mason wrote:
>
>>> Withing PG procedures at least in pgsql it is impossible to do 'money'
>>> calculations without a loss of precision.
>>
>> The point is that on *any* computer it's impossible to perform arbitrary
>> calculations to infinite precision (i.e. "without a loss of precision as
>> you put it).

> Monetary values have always been an issue with computers. For a while, at
> least in the mainframe world of decades ago, binary-coded decimals (BCD)
> were a working approach.

Yes, packed decimal is a standard way to handle money with no loss of
precision. And "for a while" would be over 50 years, as packed decimal
is still in use today. All banks rely on it. The best way to avoid
loss of precision with decimal is to use decimal representation, and not
convert to binary at all. There is no reason why PG could not support
packed decimal.

--
Guy Rouillier

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-10-05 02:30:54 Re: ERROR: column "id" inherits conflicting default values
Previous Message Scott Ribe 2009-10-05 02:06:42 Re: ERROR: column "id" inherits conflicting default values