Hacker News new | ask | show | jobs
by kadoban 1254 days ago
In any language I can think of, 0 and 0.0 are the same, once you're comparing them against a double.
1 comments

Technically what is happening behind the scenes is that for most languages the compiler/interpreter will promote the integer to a double to avoid foot guns.

Nevertheless integer comparisons with any kind of floating point is not a wise choice.

The idiomatic way to compare a double would be to take into account whatever is the double precision epsilon for that language. Or just use the greater/less than like they have in the subsequent if statements in the original code snippet.