4 ms·
Still, the comparison ratio == threshold has very little chance to turn out true. When you want to check whether A >= B (where A and B are numbers represented
by scscsc 8y ago
Still, the comparison ratio == threshold has very little chance to turn out true.
When you want to check whether A >= B (where A and B are numbers represented as floats), you would probably want to use the check A >= B - epsilon.
- geofft 8y agoIt only has little chance to turn out true if they're calculated in different ways and accumulate different error. If you're e.g. dividing two pairs of integers and comparing them, regular equality is likely to be fine. A relevant question is what epsilon should be.
- melkiaur 8y agoI disagree strongly. It looks obvious to me that they can be equal and that this is a special case. The comparison is done only after checking for A<B, and only if a boolean called "ActiveIfEqual" is true. I mean, I don't know how much more obvious they could have made it.
- benj111 8y agoAll edge cases have very little chance of being true, and I would hazard a guess that most of a developers time, and most code is spent on edge cases. So I'm not sure you can argue against a piece of code on the basis of likelihood.