Hacker News new | ask | show | jobs
by burnt-resistor 59 days ago
Numeric comparison implies subtraction or similar a - b sign and zero extraction at some lower level (in an ALU micro-op perhaps), so that's duplicated effort of a - b unless it can be optimized away.

    match a - b {
      d if d >= 0.0 => d < f64::EPSILON,
      d => d >= -f64::EPSILON, /* true if -EPSILON to -0.0 */
    }
https://godbolt.org/z/71PGzd7oa