Problems with ... Convert ?
I am getting a very strange error.
I have a C# application that has this code :
double a = 0;
double b = 0;
double c = 0;
In the code, the values for "a", "b" and "c" changes and gets these values:
a = 1716
b = Convert.ToDouble(and gets a value from the database, in this case the value in the field is 0) so b will look like this :
b = Convert.ToDouble(0)
and c is like b but the value in the database field is 1716 so:
b = Convert.ToDouble(1716)
Now we have this situation :
a = 1716
b = 0
c = 1716
Later in the code there's a formula like this :
a -= (b + c)
Theorically I would get a value of 0 (zero) for "a" because :
a = 1716 - (0 + 1716)
so
a = 0
The problem is that I'm not getting 0 but a very strange value like this :
-2,273456E-13
that is equal to : 0,00000000556453 (or somethink like that)
And in the code if value of "a" is different from 0 it does not allow you to continue with other options, but I need to continue with those options because for me, "a" is equal to 0.
The questions are :
how is it possible that 1716 - (0 + 1716) is not equal to 0 but equal to -2,273456E-13 ?!?!?!?!?!?!?
What's going on ?, what's wrong ?, how can I solve this problem ? is it a problem related to the Convert.ToDouble ?
At this point I can't check if the value of "a" is <= 0 to set the value for "a" to 0 because "a" can contain negative values, so I don't know how to solve this problem.
Any Ideas ?
Thank you all

