| Crates.io | signum-sign |
| lib.rs | signum-sign |
| version | 0.1.4-beta.2 |
| created_at | 2023-11-28 19:18:23.956+00 |
| updated_at | 2023-11-30 12:35:06.906121+00 |
| description | Adds the signum function to Rust |
| homepage | https://github.com/mangopanda455/signum |
| repository | https://github.com/mangopanda455/signum |
| max_upload_size | |
| id | 1052289 |
| size | 3,627 |
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.
cargo add signum-sign
use signum_sign::sgn;
fn main() {
println!("{}, {}, {}", sgn(0), sgn(-2), sgn(2)); // Outputs "0, -1, 1"
}
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.
use signum_sign::heron;
fn main() {
println!("{}", heron(2.0)); // Outputs "1.414213562373095"
}