Re: [HACKERS] Warning!!

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
Cc: lockhart(at)alumni(dot)caltech(dot)edu (Thomas G(dot) Lockhart), pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Warning!!
Date: 1998-11-04 21:19:15
Message-ID: 9291.910214355@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

darcy(at)druid(dot)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

Browse pgsql-hackers by date

  From Date Subject
Next Message Jackson, DeJuan 1998-11-04 21:32:28 RE: [HACKERS] 11/4/98 Snapshot
Previous Message Bruce Momjian 1998-11-04 20:01:40 Re: [HACKERS] latest snapshot crashes backend