Problems with precision

From: Jan Valenta (jvalenta@mail.cern.ch)
Date: Thu Nov 18 1999 - 03:11:33 MET


Hi all,
I've written and debugged numerical program in C++. It works perfectly
under NT and Linux (g++), but in ROOT there is some problem with 
precision. It's obvious that the problem is in the following:

root [60] Double_t x
root [61] x = 2.2
(double)2.20000000000000018e+00
root [62] Float_t s
root [63] s = 23.2
(double)2.31999999999999993e+01   

What to do with the garbage? How is it possible that there is "...0000018"
at the end of 2.2 and "...999993" instead of "23.20000" ?
At first sight it may look like a tiny deviation, but in my program it
causes some arguments to be out of ranges.
I would appreciate if someone could help.
Thanks,
		Honza Valenta    



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