Re: 'currency' question; precision/decimal meaing - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: 'currency' question; precision/decimal meaing
Date
Msg-id 20001113101411.B30018@gruby
Whole thread Raw
In response to 'currency' question; precision/decimal meaing  ("Will Fitzgerald" <fitzgerald@inetmi.com>)
Responses Re: 'currency' question; precision/decimal meaing  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: 'currency' question; precision/decimal meaing  (Jan Wieck <janwieck@Yahoo.com>)
List pgsql-general
On Fri, Nov 10, 2000 at 01:13:23PM -0500, Will Fitzgerald wrote:
> I want to store prices in a table. What's the best way to do this (since
> 'money' is deprecated)?

use int4 (or int8) and assume that the value is multipied by 100 (or another
value - depends on your local currency.
for example:
$400
i will store as
40000
$2.34
i will store as
234

this is much better, and safer than useing floating point fields.

depesz

--
hubert depesz lubaczewski
------------------------------------------------------------------------
     najwspanialszą rzeczą jaką dało nam nowoczesne społeczeństwo,
      jest niesamowita wręcz łatwość unikania kontaktów z nim ...

pgsql-general by date:

Previous
From: Denis Perchine
Date:
Subject: Problems during doing reindex on 7.0.3
Next
From: igor
Date:
Subject: Sequences in transaction