From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Gregory Stark" <stark(at)enterprisedb(dot)com> |
Cc: | "Mark Kirkwood" <markir(at)paradise(dot)net(dot)nz>, Justin <justin(at)emproshunts(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: math error or rounding problem Money type |
Date: | 2008-06-11 14:03:51 |
Message-ID: | b42b73150806110703m5e653c7fg1cbb88800b41309f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 6/8/08, Gregory Stark <stark(at)enterprisedb(dot)com> wrote:
> I don't think "as late as possible" applies with money. If you were dealing
> with approximate measurements you want to round as late as possible because
> rounding is throwing away precision. But if you're dealing with money you're
> dealing with exact quantities.
>
> There is only going to be one correct time to round and that's whenever you're
> creating an actual ledger item or order line item or whatever. Once you've
> calculated how much interest to credit or whatever you have to make that
> credit an exact number of cents and the $0.004 you lost or gained in rounding
> never comes up again.
Completely correct. In a proper accounting system you can only pull
from a very limited subset of arithmetic operations. 'rounding' is
not one of them except in the special case you mention above.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Zdenek Kotala | 2008-06-11 14:11:59 | Proposal: Multiversion page api (inplace upgrade) |
Previous Message | Gregory Stark | 2008-06-11 08:40:12 | Re: Proposal - improve eqsel estimates by including histogram bucket numdistinct statistics |