Alberto,
Try the following with teh file junk.C below
root > .x junk.C
root > .x junk.C++ (you will see the same result with the compiler)
Error: 1 value is not allowed
//file junk.C
#include <iostream>
void junk() {
double x=1.0000007;
if (x > 1.0) {
cout << "Error: " << x << " value is not allowed" << endl;
}
}
Rene Brun
Alberto Pulvirenti wrote:
>
> Hi, I beg your pardon if I introduce in that discussion
>
> In some parts of the code I'm developing, I encountered a problem which
> seems to depend on a similar thing.
>
> I declared some Double_t variables, and put an if statement of this kind:
>
> Double_t x=...;
> if (if x > 1.0) {
> cout << "Error: " << x << " value is not allowed" << endl;
> }
>
> When executing, I got many time the following message:
>
> Error: 1 value is not allowed.
>
> Now I ask: if I put strictly X > 1.0 (not X >= 1.0), why the X = 1.0
> value is caught as a "TRUE" condition? Becaue, in different case, I
> expect to see some decimals...
>
> Cheers,
>
> Alberto
>
> Rene Brun wrote:
>
> > Hi Christophe,
> >
> > The explanation of this apparent problem is the following:
> > When you do:
> > root [1] cout << x-6.7 << endl;
> > CINT makes the difference between x (a float) and 6.7 (a double)
> > if you do
> > float x=6.7;
> > float y = 6.7
> > cout <<x-y<<endl;
> > you will get 0
> >
> > Rene Brun
> >
> > Christophe DELAERE wrote:
> >
> >> Part 1.1 Type: Plain Text (text/plain)
> >> Encoding: 7bit
> >>
> > 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.
> >
> >
> > 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
> >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:53 MET