Re: TMath::Nint

From: Marcus H. Mendenhall (marcus.h.mendenhall@vanderbilt.edu)
Date: Thu Apr 29 1999 - 17:53:24 MEST


>Many thanks for your trials guys, but ...
>Nick writes "I guess TMath::Nint() ... returns the 'nearest int value'".
>Fons writes "Nint() returns the nearest integer ... round up or down ...".
>Valery writes "... count ... money ... I hope you feel better yourself
>now ... ".
>Well, now I'm sure someone tries to take me in.

This bizarre method of rounding is sometimes called "Banker's rounding".  I
would love to see all examples of it expunged from all programming.  For
scientific purposes, the up/down bias supposedly introduced by conventional
rounding is irrelevant, unless you very often come across exact x.5
numbers.  Since money is quantized in rather large units, this happens
frequently.  With physics data, exact halves tend to be very much the
exception, and making a special rounding case for them is silly.

Unless you are actually working with a banker (and using ROOT?) you
probably should just use conventional rounding (or use Nint and ignore the
odd behavior at 0.5, but I prefer to always have 0.5 round the same way).

Marcus Mendenhall



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:32 MET