8 releases

0.1.4 Nov 29, 2023
0.1.4-beta.2 Nov 30, 2023

#552 in Math

49 downloads per month

MIT license

3KB

GitHub Workflow Status (with event) Crates.io Crates.io

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"
}

No runtime deps