Re: [HACKERS] Warning!! - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Warning!!
Date
Msg-id 9291.910214355@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Warning!!  (darcy@druid.net (D'Arcy J.M. Cain))
List pgsql-hackers
darcy@druid.net (D'Arcy J.M. Cain) writes:
>> !     *result = floor((*f) * (*c) + 0.5);

> Is this correct?  What about "select cash_mul_flt8('$1', '123.99')?"
> Wouldn't that convert it to 124.00?

No, because the cash type is actually "int".  Presumably it's scaled
up by a factor of 100 compared to what's printed --- otherwise you'd
never be able to represent pennies at all.  So the "round to nearest
integer" logic depicted above is really rounding to nearest penny.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] latest snapshot crashes backend
Next
From: "Jackson, DeJuan"
Date:
Subject: RE: [HACKERS] 11/4/98 Snapshot