Floating Point, how much can I trust less than / greater than comparisons?
问题 Let's say I have two floating point numbers, and I want to compare them. If one is greater than the other, the program should take one fork. If the opposite is true, it should take another path. And it should do the same thing, if the value being compared is nudged very slightly in a direction that should still make it compare true. It's a difficult question to phrase, so I wrote this to demonstrate it - float a = random(); float b = random(); // always returns a number (no infinity or NaNs)