Trait malachite_base::num::arithmetic::traits::SqrtAssignRem

source ·
pub trait SqrtAssignRem {
    type RemOutput;

    // Required method
    fn sqrt_assign_rem(&mut self) -> Self::RemOutput;
}
Expand description

Replaces a number with the floor of its square root, returning the remainder.

Required Associated Types§

Required Methods§

source

fn sqrt_assign_rem(&mut self) -> Self::RemOutput

Implementations on Foreign Types§

source§

impl SqrtAssignRem for u8

source§

fn sqrt_assign_rem(&mut self) -> u8

Replaces an integer with the floor of its square root, and returns the remainder (the difference between the original integer and the square of the floor).

$f(x) = x - \lfloor\sqrt{x}\rfloor^2$,

$x \gets \lfloor\sqrt{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type RemOutput = u8

source§

impl SqrtAssignRem for u16

source§

fn sqrt_assign_rem(&mut self) -> u16

Replaces an integer with the floor of its square root, and returns the remainder (the difference between the original integer and the square of the floor).

$f(x) = x - \lfloor\sqrt{x}\rfloor^2$,

$x \gets \lfloor\sqrt{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type RemOutput = u16

source§

impl SqrtAssignRem for u32

source§

fn sqrt_assign_rem(&mut self) -> u32

Replaces an integer with the floor of its square root, and returns the remainder (the difference between the original integer and the square of the floor).

$f(x) = x - \lfloor\sqrt{x}\rfloor^2$,

$x \gets \lfloor\sqrt{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type RemOutput = u32

source§

impl SqrtAssignRem for u64

source§

fn sqrt_assign_rem(&mut self) -> u64

Replaces an integer with the floor of its square root, and returns the remainder (the difference between the original integer and the square of the floor).

$f(x) = x - \lfloor\sqrt{x}\rfloor^2$,

$x \gets \lfloor\sqrt{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type RemOutput = u64

source§

impl SqrtAssignRem for u128

source§

fn sqrt_assign_rem(&mut self) -> u128

Replaces an integer with the floor of its square root, and returns the remainder (the difference between the original integer and the square of the floor).

$f(x) = x - \lfloor\sqrt{x}\rfloor^2$,

$x \gets \lfloor\sqrt{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type RemOutput = u128

source§

impl SqrtAssignRem for usize

source§

fn sqrt_assign_rem(&mut self) -> usize

Replaces an integer with the floor of its square root, and returns the remainder (the difference between the original integer and the square of the floor).

$f(x) = x - \lfloor\sqrt{x}\rfloor^2$,

$x \gets \lfloor\sqrt{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type RemOutput = usize

Implementors§