That's quite interesting.  I wasn't aware of this preference for rounding
towards even in numerical analysis.  Still I wonder why Microsoft chose to
use this rounding method instead of "normal" rounding for VB and the .NET
System.Math class -- after all, both of them aren't really terribly useful
for numerical computing anyway.  On the other hand, the Fortran standard
(which certainly is used in numerical computing) mandates normal rounding
for ANINT and NINT, and not rounding towards even.  Go figure...

Just to clarify, I was not suggesting rounding up (towards positive
infinity) but rounding towards the nearest whole number.  Amazingly, the
.NET Framework does not provide a method for this task so you have to roll
your own.  (Many people think Floor or Ceiling do this but that's incorrect
-- you have to pick either of these methods based on the sign of the value.)

Chris

At 09:13 28.08.2002 -0500, you wrote:
>Just as an aside (and maybe not a very interesting one), rounding toward
>the even number is actually considered standard, at least for computers,
>even if it isn't what anyone thinks of when they think of rounding. When
>I took a numerical analysis course in college we were taught to do this
>since it minimized errors introduced through rounding. The thought is
>that, if you always round up at .5, you will introduce more error than
>if you round toward the even number, since you then have a better chance
>of the rounding operations evening each other out over time.
>
>If you look on Google for IEEE rounding, I think there's some documents
>out there on this. You will see the round toward even referred to as
>something like standard rounding or rounding toward the nearest
>representative value, while rounding up will probably be referred to as
>rounding toward positive infinity.
>
>Mark

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to