TMath::Nint
Jacek M. Holeczek (holeczek@us.edu.pl)
Thu, 29 Apr 1999 17:40:41 +0200 (MET DST)
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.
----------------------------------------------
#include <stream.h>
main()
{
int i, j;
float x;
//double x;
for ( i=0; i< 101; i++)
{
x = -5.0 + 0.1*i;
#if 1
j = int(x+0.5);
if (x + 0.5 == float(j) && j & 1) j--;
//if (x + 0.5 == double(j) && j & 1) j--;
#else
j = TMath::Nint(x);
#endif
cout << i << " " << x << " " << j << endl;
}
}
----------------------------------------------
Jacek.