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 19:48:44
Message-ID: 4ACA4D9C.8030401@burntmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christophe Pettus wrote:
>
> On Oct 4, 2009, at 7:09 PM, Guy Rouillier wrote:
>> There is no reason why PG could not support packed decimal.
>
> Is that not NUMERIC?

No, that is not NUMERIC. All numeric types are stored as binary
representations. Packed decimal is not. Perhaps an example would
clarify. The number 1234 would be represented as follows:

binary: 10011010010
packed decimal: 12 34

Packed decimal needs to be able to represent 10 distinct characters,
0-9, so it uses half a byte for each. So a 4 digit number can be
represented in 2 bytes (for simplicity, I'm ignoring sign. That takes a
half byte.)

The IBM implementation provides a corresponding arithmetic library to
use packed decimal. These numbers are never converted to binary, so
there is no loss in precision.

--
Guy Rouillier

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2009-10-05 19:55:10 Re: How useful is the money datatype?
Previous Message Gerhard Wiesinger 2009-10-05 18:28:25 Re: Limit of bgwriter_lru_maxpages of max. 1000?