Go to file
Joe Richey 0445b3e5c1
Use improved algorithm that only uses shifts
This new algorithm (taken from Wikipedia) only uses shifts, addditions,
and subtrations. On my x86_64 machine, the benchmarks are over twice as
fast.

This also takes num-traits as a dependancy, so that the implementation
can be a normal generic function, instread of a macro.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-09-08 04:50:50 -07:00
benches benches: Add benchmarks 2020-09-07 20:16:28 -07:00
src Use improved algorithm that only uses shifts 2020-09-08 04:50:50 -07:00
.gitignore First commit 2017-10-23 13:29:42 +01:00
Cargo.toml Use improved algorithm that only uses shifts 2020-09-08 04:50:50 -07:00
LICENSE-APACHE First commit 2017-10-23 13:29:42 +01:00
LICENSE-MIT First commit 2017-10-23 13:29:42 +01:00
README.md First commit 2017-10-23 13:29:42 +01:00

README.md

Integer square root

This module contains the single trait IntegerSquareRoot and implements it for primitive integer types.

Example

extern crate integer_sqrt;

// `use` trait to get functionality
use integer_sqrt::IntegerSquareRoot;

assert_eq!(4u8.integer_sqrt(), 2);