signum-sign

Crates.iosignum-sign
lib.rssignum-sign
version0.1.4-beta.2
created_at2023-11-28 19:18:23.956+00
updated_at2023-11-30 12:35:06.906121+00
descriptionAdds the signum function to Rust
homepagehttps://github.com/mangopanda455/signum
repositoryhttps://github.com/mangopanda455/signum
max_upload_size
id1052289
size3,627
(mangopanda455)

documentation

https://docs.rs/signum

README

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

Heron:

This branch also adds the Heron method of approximating the square root of a number. This method is more accurate than the Babylonian method, but is slower.

THIS IS WILDLY INNEFICIENT AND IS MORE OF A PROOF OF CONCEPT THAN ANYTHING ELSE.

Usage:

use signum_sign::heron;

fn main() {
    println!("{}", heron(2.0)); // Outputs "1.414213562373095"
}
Commit count: 19

cargo fmt