From: Peter Eisentraut on 18 Jul 2010 05:00 On lör, 2010-07-17 at 07:20 -0700, Andy Balholm wrote: > On Jul 17, 2010, at 3:20 AM, Peter Eisentraut wrote: > > > On fre, 2010-07-16 at 10:31 -0400, Tom Lane wrote: > >> 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. > > > > Why is it approximate? Aren't money values really integers? > > $1.00 / 3.00 = 0.333333333333333333333333333333333333333333333333... By that reasoning, numeric / numeric should also yield float. -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Peter Eisentraut on 18 Jul 2010 05:04 On lör, 2010-07-17 at 10:00 -0500, Kevin Grittner wrote: > True. If we added money * numeric, then it would make more sense to > have money / money return numeric. On the other hand, I couldn't > come up with enough use cases for that to feel that it justified the > performance hit on money / money for typical use cases -- you > normally want a ratio for things where float8 is more than > sufficient; and you can always cast the arguments to numeric for > calculations where the approximate result isn't good enough. > Basically, once we agreed to include casts to and from numeric, it > seemed to me we had it covered. I have never used the money type, so I'm not in a position to argue what might be typical use cases, but it is well understood that using floating-point arithmetic anywhere in calculations involving money is prohibited by law or business rules in most places. So when I read that multiplications or divisions involving the money type use float, to me that means the same as "never use the money type, it's broken". -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Tom Lane on 18 Jul 2010 10:27
Peter Eisentraut <peter_e(a)gmx.net> writes: > I have never used the money type, so I'm not in a position to argue what > might be typical use cases, but it is well understood that using > floating-point arithmetic anywhere in calculations involving money is > prohibited by law or business rules in most places. So when I read that > multiplications or divisions involving the money type use float, to me > that means the same as "never use the money type, it's broken". [ shrug... ] A lot of people think that about the money type, all for different reasons. This particular argument seems tissue-thin to me, mainly because the same people who complain "it must be exact" have no problem rounding off their results to the nearest pfennig or whatever. Also, you seem not to have absorbed the fact that changing the output to numeric *will not make the result exact anyway*. If the point of a business rule of this sort is to prohibit inexact calculations, then having it flag cash / cash as inexact is a Good Thing. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers |