Re: dividing money by money - Mailing list pgsql-hackers

From Andy Balholm
Subject Re: dividing money by money
Date
Msg-id DEC50D2F-6A1B-408E-89E0-F42556674553@balholm.com
Whole thread Raw
In response to Re: dividing money by money  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: dividing money by money
List pgsql-hackers
On Jul 15, 2010, at 7:25 PM, Tom Lane wrote:

> * I didn't like this bit in cash_numeric():
>
>     result->n_sign_dscale = NUMERIC_SIGN(result) | fpoint;
>
> Not only is that unwarranted chumminess with the implementation of
> numeric, it's flat-out wrong.  If the result isn't exactly the right
> number of digits (say, it's 12.33999999 instead of the desired 12.34)
> this just hides the extra digits, it doesn't make the result correct.
> The right way is to use numeric_round(), which not only sets the dscale
> where we want it but rounds off any inaccuracy that might have crept in
> from the division.

Sorry about that. Is there documentation anywhere for backend functions and types? I couldn't find any, so I just
lookedthrough numeric.h to see what looked like it might work. I didn't find numeric_round, since it's declared in
builtins.h.

pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: imessages up-date
Next
From: Markus Wanner
Date:
Subject: Re: imessages up-date