Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pedro Gimeno <pgsql-004(at)personal(dot)formauri(dot)es>, rschaaf(at)commoninf(dot)com, "pgsql-bugs\(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Date: 2015-03-27 23:55:50
Message-ID: 87384q2ejg.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "Dean" == Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:

Dean> I'm not convinced that it is a good idea to change the default
Dean> rounding mode for numeric.

Dean> For one thing, numeric is commonly used for monetary data, and
Dean> changing the default rounding mode might well break existing
Dean> applications where rounding is important, and which rely on the
Dean> current behaviour.

On the other hand, we've had complaints (on IRC) from people doing
calculations with monetary data who complain that we don't do
round-to-even (which is widely known as "Banker's Rounding") as their
requirements demand.

To quote the last person who brought it up there:

>> We have strict accounting practice to follow -- and our CFO has
>> instructed to use even-rounding (aka bankers rounding)... and to not
>> use our typical rounding behavior we learned in 1st grade. :)

Dean> Adding a version of round() with support for a choice of various
Dean> rounding modes might be a better way to go.

There's still the issue of casting to ::numeric(m,n) to consider, and
whatever internal rounding is being done in division and numeric
functions.

Dean> Also, if the default is being changed, I think that merits wider
Dean> discussion (on a thread with a more appropriate title) to see if
Dean> it is likely to be an issue for anyone.

Absolutely.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message wiltoma 2015-03-28 08:49:31 BUG #12912: pgAdmin III : set fonts preferences makes pgAdmin to crash
Previous Message Jeff Davis 2015-03-27 23:27:49 Re: pg_get_constraintdef() doesn't always give an equal constraint