- Many of the #rust floating-point math functions have a note: "The precision of this function is non-deterministic. This means it varies by platform, Rust version, and can even differ within the same execution from one invocation to the next." When would results vary between invocations? #rustlangFeb 5, 2026 02:21
- libm implementations are a little slower sometimes, but imo it is well worth the cost to achieve real cross-platform consistency, especially in scientific computing
- I recommend using libm for any functions with that label unless you know they'll get compiled to a single instruction on your target platform (like sqrt() for example)
- If you load a C module that uses -ffast-math, or if libc gets hooked and modified, it can change floating-point calculation behavior in your otherwise-separate program. I think there are also some function implementations that don't write all the bits of the float in some cases, so you get some junk