Hi, I would like to know how I could compare the number initialized as double result to the actual number -9.25596e+061.
Since it is the only comparison possibility I know, I naturally tried: if (result!=-9.25596e+061)
which compiles fine but doesn't actually work (whether result is this number or not, the if loop is ignored...)
The problem may be that your double may be rounding. As a result, though the two numbers should be exactly equal, when performing the operation the computer may round slightly making the two numbers not strictly equal. You could try something like this.
1 2 3 4 5 6
double result=<some number>;
double epsilon=<define your limit here>;
double test=-9.25596e+061;
if (abs(test-result)<epsilon) {
...
}
To use this you would need to know what a reasonable number for epsilon would be, and that would be determined by the kind of problem you are trying to solve. This is just a simple solution, there are better solutions out there but they are more complicated.
Since the first number is a bit closer to -9.25596e+061, it is what's stored when you attempt to write -9.25596e+061 to a double, and that's what you need to be comparing with, if you're using exact comparison.
The usual approach is to use an appropriately scaled epsilon, as already mentioned.