The MSDN article mentions when fp: fast mode is enabled, operations such as incremental identifier ( aΒ±0.0 = a , 0.0-a = -a ) are not safe. Is there any example that a+0 != a in this mode?
EDIT: As mentioned below, such a problem usually occurs when comparing. My problem is in comparison, psedocode is as follows:
for(i=0;i<v.len;i++) { sum+=v[i]; if( sum >= threshold) break; }
It breaks after adding the value 0 ( v[i] ). v[i] not calculated, he is appointed. I understand that if my v[i] is the result of the calculation, rounding can come into play, but why, although I give v[i] null value, I still have sum < threshold , but sum + v[i] >= threshold ?
c ++ floating-point unsafe
Steven
source share