Search code examples
c++comparisonfloating-accuracydeterministicnon-deterministic

Floating point comparison - Result between different runs


I know that I can not compare two floating point or double numbers for absolute equality on C++/C. If for some reason, I write a if condition which uses the absolute equality, is it guaranteed that the if condition will return the same result on different runs of the program for same data? Or it is purely non-deterministic and the result can vary?


Solution

  • For the same compiled binary and on the same PC, results should be the same. If you use another compiler or another PC, results may vary.