[ROOT] discrepancies with floats

From: Christophe DELAERE (delaere@fynu.ucl.ac.be)
Date: Fri May 10 2002 - 13:58:57 MEST


Hi rooters,

I've noticed the following strange behaviour using ROOT 3.02/07.
When I declare a single variable, there are discrepancies between the
value entered and actual value stored, even for basic float objects.
When a float is declared and filled, the value stored is slightly
different from what is needed.
In most of the cases this is not a problem, but it can be if the
variable is multiplied by a large interger.

Is this fact known ?  Is there a simple solution?

Thanks,
Christophe.

p.s: Here is a c&p of a minimal session.
I'm running linux redhat 6.2 with a precompiled ROOT 3.02/07.

uname -a
Linux cmswks6.fynu.ucl.ac.be 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000
i686 unknown



  *******************************************

  *                                         *

  *        W E L C O M E  to  R O O T       *

  *                                         *

  *   Version   3.02/07  20 February 2002   *

  *                                         *

  *  You are welcome to visit our Web site  *

  *          http://root.cern.ch            *

  *                                         *

  *******************************************

Compiled for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.25, Jan 6 2002

Type ? for help. Commands must be C++ statements.

Enclose multiple statements between { }.

root [0] Float_t x = 6.7

root [1] cout << x-6.7 << endl;

-1.90735e-07

root [2] cout << x << endl;

6.7

root [3] x

(Float_t)6.69999980926513672e+00

--
+-----------------------------------------------------------\|/---+
| Christophe DELAERE            office: e253               !o o!  |
| UCL - FYNU                    phone : 32-(0)10-473234    ! i !  |
| chemin du cyclotron, 2        fax   : 32-(0)10-452183     `-'   |
| 1348 Louvain-la-Neuve BELGIUM e-mail: delaere@fynu.ucl.ac.be    |
+-----------------------------------------------------------------+



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