TMath::Nint

From: Jacek M. Holeczek (holeczek@us.edu.pl)
Date: Thu Apr 29 1999 - 17:40:41 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.
----------------------------------------------
#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.



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