Re: 'currency' question; precision/decimal meaing

From: hubert depesz lubaczewski <depesz(at)depesz(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: 'currency' question; precision/decimal meaing
Date: 2000-11-13 09:14:12
Message-ID: 20001113101411.B30018@gruby
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 ...

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Havrylyak Roma 2000-11-13 10:32:02 Locale money-type support
Previous Message Denis Perchine 2000-11-13 08:37:41 Problems during doing reindex on 7.0.3