Skip to main content

Module math

Module math 

Source
Expand description

Floating-point primitives routed to std or libm.

Routing every transcendental call through this module lets the crate build as no_std: with default-features = false, features = ["libm"] the same code links against pure-Rust libm.

Public because the rule applies to the whole crate family: magnetic models and estimators call these and thereby build for bare metal and produce the same results on every target. Also provides the conversions and guarded casts numeric code needs.

Constants§

RELATIVE_TOLERANCE
Relative tolerance for comparing computed results.

Functions§

abs
Absolute value.
acos
Arccosine in [0, π]; NaN outside [-1, 1].
asin
Arcsine in [-π/2, π/2]; NaN outside [-1, 1].
atan
Arctangent in [-π/2, π/2].
atan2
Four-quadrant arctangent of y / x, in [-π, π].
ceil
Ceiling.
copysign
magnitude with the sign of sign.
cos
Cosine, radians.
count_to_f64
Count as f64. Counts here are far below 2^53, so the conversion is exact.
exp
eˣ.
hypot
√(x² + y²) without intermediate overflow.
is_effectively_zero
Whether a value is zero relative to scale, the magnitude of its operands.
is_integral
Whether a value is an integer.
ln
Natural logarithm; NaN for negative input, -∞ for zero.
round
Round to nearest, halves away from zero.
round_to_i32
Rounds a value known to be within i32 range. Callers pass angles bounded by 360.
sin
Sine, radians.
sqrt
Square root; NaN for negative input.
tan
Tangent, radians.
to_degrees
Radians to degrees.
to_radians
Degrees to radians.
to_usize
Truncates a small non-negative value to usize. Callers bound it first; out-of-range input yields zero.
trunc
Truncate towards zero.