From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: He Weiping(Laser Henry) <laser@zhengmai.com.cn>
Cc: pgsql-docs@postgresql.org
Subject: Re: some errors and/or bugs?
Date: Wed, 20 Dec 2000 14:35:44 -0500
Message-ID: <10051.977340944@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.30.0012191732170.1000-100000@peter.localdomain>
References: <Pine.LNX.4.30.0012191732170.1000-100000@peter.localdomain>
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> It's correct, if the underlying float arithmetic is IEEE-compliant.
>> Rounding for exact half-integral values is supposed to be "round to
>> nearest even". So 42.5 goes to 42, but 43.5 goes to 44.
>>
>> I notice our NUMERIC rounding code does not do that ... perhaps it
>> should.
> More precisely, an IEEE-compliant system would offer the choice of
> rounding up, rounding down, rounding toward zero, or rounding toward even.
> I would guess that the default is merely the potentially best performing.
Hmm. Round-toward-even is preferred by numerical analysts on the theory
that it introduces less systematic bias than simpler rounding rules.
(If you always round half-integral values in the same direction, then
your results are slightly biased, just as if you'd set the up/down split
point at say 0.4 instead of 0.5.) However this theory only holds if you
assume an imprecise starting value. That's a reasonable assumption for
float arithmetic, but not so reasonable for type numeric.
> We could offer these options (much more easily) for the numeric case, but
> since numeric is very often used for business type applications, the
> customary rounding method (up) should be preferred.
You're probably right, we shouldn't change it.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter_e@gmx.net, laser@zhengmai.com.cn
Subject: Re: some errors and/or bugs?
In-Reply-To: <10051.977340944@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox