I know that you can not rely on equality between values of double or decimal type on parallelism, but I am thinking I have 0 special cases.
While I can understand the imprecisions between 0.00000000000001 and 0.00000000000002, 0 seems to be very difficult to mess themselves down because it's just nothing if you are not doing anything, then it's nothing more is not.
But I do not know much about this subject, so this is not for me.
double x = 0.0; Return (x == 0.0)? right wrong;
Is this always right?
this safe to expect that the comparison true < / Code> and if only the dual variable has the value of exactly
0.0
(of course, the case is in your original code snippet). It is compatible with the words of the operator ==
. a == b
means " a
is equal to b
".
It is not safe (because it is not correct ) to expect that some calculations result in zero (or more commonly, floating point ) Arithmetic will become zero, whenever the result of equal calculation in pure mathematics is zero. The reason for this is that when the calculation comes into the ground, the floating point appears exact error - a concept that is not present in the actual number arithmetic in mathematics.
Comments
Post a Comment