[]Trait sp_arithmetic::traits::IntegerSquareRoot

pub trait IntegerSquareRoot {
    pub fn integer_sqrt_checked(&self) -> Option<Self>;

    pub fn integer_sqrt(&self) -> Self { ... }

A trait implementing integer square root.

Required methods

pub fn integer_sqrt_checked(&self) -> Option<Self>

Find the integer square root, returning None if the number is negative (this can never happen for unsigned types).

Loading content...

Provided methods

pub fn integer_sqrt(&self) -> Self

Find the integer square root.

See Integer_square_root on wikipedia for more information (and also the source of this algorithm)


For negative numbers (i family) this function will panic on negative input

Loading content...


impl<T> IntegerSquareRoot for T where
    T: PrimInt

Loading content...