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
u8value. 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
i8input. - i16 ๐ โ
- Returns the integer square root of any
nonnegative
i16input. - i32 ๐ โ
- Returns the integer square root of any
nonnegative
i32input. - i64 ๐ โ
- Returns the integer square root of any
nonnegative
i64input. - i128 ๐ โ
- Returns the integer square root of any
nonnegative
i128input. - 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
u8input. - u16 ๐
- Returns the integer square root of any
u16input. - u32 ๐
- Returns the integer square root of any
u32input. - u64 ๐
- Returns the integer square root of any
u64input. - u16_
stages ๐ - Takes the normalized
u16input and gets its normalized integer square root. - u32_
stages ๐ - Takes the normalized
u32input and gets its normalized integer square root. - u64_
stages ๐ - Takes the normalized
u64input and gets its normalized integer square root. - u128 ๐
- Returns the integer square root of any
u128input. - u128_
stages ๐ - Takes the normalized
u128input and gets its normalized integer square root.