Re: dividing money by money

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Andy Balholm" <andy(at)balholm(dot)com>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: dividing money by money
Date: 2010-04-01 14:57:40
Message-ID: 4BB46E140200002500030300@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

>> That's hardly an improvement if you're concerned about lack of
>> exactness.
>
> I know; I lose a couple of digits by using float8 instead of
> numeric, but it's much simpler and faster

It also has the advantage of being symmetrical with the other
operators.

> and if it returned numeric people would _think_ it was exact.

Well, I don't know how many people would expect an *exact* decimal
representation of dividing a number by three. The case which had me
concerned was specifically division by one as a "back door" cast.
With numeric we could guarantee *that* was exact.

> And if we have a cast to numeric, people who want those extra
> digits can cast to numeric before dividing.

And nobody has much reason to do the divide-by-one trick.

> But I do still have the numeric code that I tried, so if that's
> how people want to do it, I can provide it.

I'm inclined to think it's better to have an explicit cast from
money to numeric, as long as it is exact, and leave the division of
money by money as float8. It does sort of beg the question of
whether we should support a cast back in the other direction,
though. I think that would wrap this all up in a tidy package.

-Kevin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andy Balholm 2010-04-01 16:34:27 Re: dividing money by money
Previous Message Tom Lane 2010-04-01 14:27:28 Re: Syslogger tries to write to /dev/null on Windows