8 releases

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

#533 in Math

Download history 5/week @ 2024-07-23 16/week @ 2024-09-24 33/week @ 2024-10-01

59 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