8 releases
0.1.4 | Nov 29, 2023 |
---|---|
0.1.4-beta.2 | Nov 30, 2023 |
#548 in Math
59 downloads per month
3KB
Signum
Adds the signum function to Rust. The signum function or sign function will return 1 when a positive number is passed in, -1 when a negative number is passed in, or 0 when 0 is passed in.
Installation:
cargo add signum-sign
Usage:
use signum_sign::sgn;
fn main() {
println!("{}, {}, {}", sgn(0), sgn(-2), sgn(2)); // Outputs "0, -1, 1"
}