Re: [ROOT] discrepancies with floats

From: Brett Viren (bv@bnl.gov)
Date: Tue May 14 2002 - 16:14:37 MEST


Rene Brun writes:
 > Try the following with teh file junk.C below

Using cout.precision() may make things more clear:

#include <iostream>
void junk() {
   double x=1.0000007;
   if (x > 1.0) {
      cout << "Error: " << x << " value is not allowed" << endl;
      cout.precision(10);
      cout << "   or: " << x << " value is not allowed" << endl;
   }
}

root [3] .x junk.C
Error: 1 value is not allowed
   or: 1.0000007 value is not allowed


In C++ you can also use cout.setf() to switch to, eg., scientific
notation, but CINT doesn't apparently understand this(?).

-Brett.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:53 MET