Re: dividing money by money

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Andy Balholm" <andy(at)balholm(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: dividing money by money
Date: 2010-03-31 18:01:59
Message-ID: 4BB347C702000025000302A7@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andy Balholm <andy(at)balholm(dot)com> wrote:

> quotient = (float8)dividend / (float8)divisor;
> PG_RETURN_FLOAT8(quotient);

That was my first inclination, but the fact that two different
people talked about using division by '1'::money as a way to convert
money to another type has me nervous about using an approximate
type. Any chance you could rework it using numeric? I know it's
less trivial that way, but unless we provide a cast to numeric, I'm
afraid people will use the above trick, assign it to a numeric
variable or column, and then wonder why they've lost precision.

Or I guess we could leave this as you've written it and add support
for a cast from money to numeric.

-Kevin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andy Balholm 2010-03-31 18:30:38 Re: dividing money by money
Previous Message Andy Balholm 2010-03-31 17:52:54 Re: dividing money by money