L
Lionel
Hi all,
I'm facing a strang issue doing calculation on Double values. I read
some thread on the newsgroups warning about type translations (eg
Single to Double), but here I'm doing no conversion at all.
The issue I'm facing looks so basic but I'm really lost... I'm doing
all my calculations in Double, and the results are not correct. Did I
miss something?
double a, b;
a = 4.5d;
b = a + 0.10d;
Console.WriteLine(ee == 4.6d); // returns true
b = a + 0.20d;
Console.WriteLine(ee == 4.7d); // returns true
b = a + 0.10d + 0.10d;
Console.WriteLine(ee == 4.7d); // returns false !!!
b = a + 0.30d;
Console.WriteLine(ee == 4.8d); // returns true
b = a + 0.10d + 0.10d + 0.10d;
Console.WriteLine(ee == 4.8d); // same: returns false
Many thanks in advance for your help,
Best regards,
Lionel
Aulofee supervision systems (http://www.aulofee.com)
* security and log correlation
* IT asset management and inventory
* reporting
* network cartography
I'm facing a strang issue doing calculation on Double values. I read
some thread on the newsgroups warning about type translations (eg
Single to Double), but here I'm doing no conversion at all.
The issue I'm facing looks so basic but I'm really lost... I'm doing
all my calculations in Double, and the results are not correct. Did I
miss something?
double a, b;
a = 4.5d;
b = a + 0.10d;
Console.WriteLine(ee == 4.6d); // returns true
b = a + 0.20d;
Console.WriteLine(ee == 4.7d); // returns true
b = a + 0.10d + 0.10d;
Console.WriteLine(ee == 4.7d); // returns false !!!
b = a + 0.30d;
Console.WriteLine(ee == 4.8d); // returns true
b = a + 0.10d + 0.10d + 0.10d;
Console.WriteLine(ee == 4.8d); // same: returns false
Many thanks in advance for your help,
Best regards,
Lionel
Aulofee supervision systems (http://www.aulofee.com)
* security and log correlation
* IT asset management and inventory
* reporting
* network cartography
