number
Numeric helpers that the standard library does not provide.
Floating-point helpers never panic: an input with no meaningful answer (an empty slice, a
zero total, a NaN) gives None, and NaN or infinite values propagate as usual for f64.
Install
Section titled “Install”Cargo feature number (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::number.
| Item | What it does |
|---|---|
gcd | Greatest common divisor of a and b; gcd(0, 0) is 0. |
lcm | Least common multiple of a and b, or None when it does not fit in a u64. |
lerp | Linear interpolation between from and to: from at t = 0, to at t = 1. |
mean | Arithmetic mean of values, or None when it is empty. |
median | Median of values, or None when it is empty or contains a NaN. |
percentage | What percent part is of total, or None when total is zero. |
round_to | Rounds value to decimals decimal places, half away from zero. |
