Expand description
These functions use the Karatsuba square root algorithm to compute the integer square root for the primitive integer types.
The signed integer functions can only handle nonnegative inputs, so that must be checked before calling those.
Macrosยง
- first_
stage ๐ - Generates the first stage of the computation after normalization.
- last_
stage ๐ - Generates the last stage of the computation before denormalization.
- middle_
stage ๐ - Generates a middle stage of the computation.
- signed_
fn ๐ - Generates an
i*
function that returns the integer square root of any nonnegative input of a specific signed integer type. - unsigned_
fn ๐ - Generates a
u*
function that returns the integer square root of any input of a specific unsigned integer type.
Constantsยง
- U8_
ISQRT_ ๐WITH_ REMAINDER - This array stores the integer square roots and remainders of each
u8
value. For example,U8_ISQRT_WITH_REMAINDER[17]
will be(4, 1)
because the integer square root of 17 is 4 and because 17 is 1 higher than 4 squared.
Functionsยง
- i8 ๐ โ
- Returns the integer square root of any
nonnegative
i8
input. - i16 ๐ โ
- Returns the integer square root of any
nonnegative
i16
input. - i32 ๐ โ
- Returns the integer square root of any
nonnegative
i32
input. - i64 ๐ โ
- Returns the integer square root of any
nonnegative
i64
input. - i128 ๐ โ
- Returns the integer square root of any
nonnegative
i128
input. - panic_
for_ ๐negative_ argument - Instantiate this panic logic once, rather than for all the isqrt methods on every single primitive type.
- u8 ๐
- Returns the integer square root of any
u8
input. - u16 ๐
- Returns the integer square root of any
u16
input. - u32 ๐
- Returns the integer square root of any
u32
input. - u64 ๐
- Returns the integer square root of any
u64
input. - u16_
stages ๐ - Takes the normalized
u16
input and gets its normalized integer square root. - u32_
stages ๐ - Takes the normalized
u32
input and gets its normalized integer square root. - u64_
stages ๐ - Takes the normalized
u64
input and gets its normalized integer square root. - u128 ๐
- Returns the integer square root of any
u128
input. - u128_
stages ๐ - Takes the normalized
u128
input and gets its normalized integer square root.