2 ms·
In any language I can think of, 0 and 0.0 are the same, once you're comparing them against a double.
by kadoban 4y ago
In any language I can think of, 0 and 0.0 are the same, once you're comparing them against a double.
- DoingIsLearning 4y agoTechnically 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.