Module libm
Floating-point math functions for no_std.
libm is a pure-Rust port of the C library's math routines,
maintained by the Rust project alongside compiler-builtins.
The interesting math operations on f32 and f64 —
sin, exp, pow, sqrt, and friends —
are inherent methods in std only.
They are absent from core because the standard library
implements them by calling the platform's C libm,
which a no_std target may not have.
Code written against core therefore needs this crate instead.
Its other use is reproducibility:
libm computes the same results on every platform,
while the system libm may not.
Examples
Math on f64 and f32 without std:
// `core` has no `f64::sqrt`, so call the free function.
let x = sqrt;
assert!;
// The `f32` variants carry an `f` suffix, as in C.
let y = sqrtf;
assert!;
Dispatching by float width with Libm:
use Libm;
// `Libm<T>` selects the suffixed function matching `T`.
assert_eq!;
assert_eq!;