Re: dividing money by money

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Andy Balholm" <andy(at)balholm(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: dividing money by money
Date: 2010-07-16 14:31:50
Message-ID: 15577.1279290710@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> I didn't see any discussion about why this should return float8
>> rather than numeric. It seems wrong to use float8 for this.

> That discussion took place several months ago on the -bugs list.
> I'll paste some links from a quick search of the archives below.
> Since multiplication of money is by float8 and not numeric, it
> ultimately seemed more consistent to me to have the results of
> division be float8. I felt that as long as we had a cast between
> money and numeric, someone could always cast to numeric if they
> wanted that style of division.

Yeah. The other argument that I found convincing was that if the
operator was defined to yield numeric, people might think that
the result was exact ... which of course it won't be, either way.
Choosing float8 helps to remind the user it's an approximate quotient.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-07-16 14:36:48 Re: dividing money by money
Previous Message Jan Urbański 2010-07-16 14:29:01 review: psql: edit function, show function commands patch

Browse pgsql-www by date

  From Date Subject
Next Message Tom Lane 2010-07-16 14:36:48 Re: dividing money by money
Previous Message Andy Balholm 2010-07-16 14:13:40 Re: dividing money by money