Faster floating point math with Rust's new API

(pythonspeed.com)

45 points | by subset 5 days ago ago

3 comments

  • GeertB 5 days ago

    Signed integer addition is only associative when overflow is defined to wrap around like unsigned arithmetic. This condition is matched here, because only debug builds panic on overflow. However, it's a bit of a gray area that the article completely ignores.

    • thrance 30 minutes ago

      Unlike C, Rust's signed arithmetic is fully specified to wrap around.

  • rob74 an hour ago

    I'm not an expert on floating point math, but the "Does adding a small number do nothing?" example caught my eye, because the numbers used are constants, which are arbitrary precision in some languages (https://stackoverflow.com/questions/57511935/what-is-the-pur...). For instance, Go answers the question with false (but still prints out "1e+16" when you try to print 1e16 + 1): https://go.dev/play/p/mSAktWpCRJA