pub trait RootAssignRem<POW> {
type RemOutput;
// Required method
fn root_assign_rem(&mut self, exp: POW) -> Self::RemOutput;
}Expand description
Replaces a number with the floor of its $n$th root, returning the remainder.
Required Associated Types§
Required Methods§
fn root_assign_rem(&mut self, exp: POW) -> Self::RemOutput
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl RootAssignRem<u64> for u8
impl RootAssignRem<u64> for u8
Source§fn root_assign_rem(&mut self, exp: u64) -> u8
fn root_assign_rem(&mut self, exp: u64) -> u8
Replaces an integer with the floor of its $n$th root, and returns the remainder (the difference between the original integer and the $n$th power of the floor).
$f(x, n) = x - \lfloor\sqrt[n]{x}\rfloor^n$,
$x \gets \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits():
constant for widths up to 64 bits and for exponents greater than 2, where a
floating-point approximation is refined with $O(1)$ adjustments; 128-bit square
roots (exp == 2) fall back to an $O(n)$ binary search.
§Panics
Panics if exp is zero.
§Examples
See here.
type RemOutput = u8
Source§impl RootAssignRem<u64> for u16
impl RootAssignRem<u64> for u16
Source§fn root_assign_rem(&mut self, exp: u64) -> u16
fn root_assign_rem(&mut self, exp: u64) -> u16
Replaces an integer with the floor of its $n$th root, and returns the remainder (the difference between the original integer and the $n$th power of the floor).
$f(x, n) = x - \lfloor\sqrt[n]{x}\rfloor^n$,
$x \gets \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits():
constant for widths up to 64 bits and for exponents greater than 2, where a
floating-point approximation is refined with $O(1)$ adjustments; 128-bit square
roots (exp == 2) fall back to an $O(n)$ binary search.
§Panics
Panics if exp is zero.
§Examples
See here.
type RemOutput = u16
Source§impl RootAssignRem<u64> for u32
impl RootAssignRem<u64> for u32
Source§fn root_assign_rem(&mut self, exp: u64) -> u32
fn root_assign_rem(&mut self, exp: u64) -> u32
Replaces an integer with the floor of its $n$th root, and returns the remainder (the difference between the original integer and the $n$th power of the floor).
$f(x, n) = x - \lfloor\sqrt[n]{x}\rfloor^n$,
$x \gets \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits():
constant for widths up to 64 bits and for exponents greater than 2, where a
floating-point approximation is refined with $O(1)$ adjustments; 128-bit square
roots (exp == 2) fall back to an $O(n)$ binary search.
§Panics
Panics if exp is zero.
§Examples
See here.
type RemOutput = u32
Source§impl RootAssignRem<u64> for u64
impl RootAssignRem<u64> for u64
Source§fn root_assign_rem(&mut self, exp: u64) -> u64
fn root_assign_rem(&mut self, exp: u64) -> u64
Replaces an integer with the floor of its $n$th root, and returns the remainder (the difference between the original integer and the $n$th power of the floor).
$f(x, n) = x - \lfloor\sqrt[n]{x}\rfloor^n$,
$x \gets \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits():
constant for widths up to 64 bits and for exponents greater than 2, where a
floating-point approximation is refined with $O(1)$ adjustments; 128-bit square
roots (exp == 2) fall back to an $O(n)$ binary search.
§Panics
Panics if exp is zero.
§Examples
See here.
type RemOutput = u64
Source§impl RootAssignRem<u64> for u128
impl RootAssignRem<u64> for u128
Source§fn root_assign_rem(&mut self, exp: u64) -> u128
fn root_assign_rem(&mut self, exp: u64) -> u128
Replaces an integer with the floor of its $n$th root, and returns the remainder (the difference between the original integer and the $n$th power of the floor).
$f(x, n) = x - \lfloor\sqrt[n]{x}\rfloor^n$,
$x \gets \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits():
constant for widths up to 64 bits and for exponents greater than 2, where a
floating-point approximation is refined with $O(1)$ adjustments; 128-bit square
roots (exp == 2) fall back to an $O(n)$ binary search.
§Panics
Panics if exp is zero.
§Examples
See here.
type RemOutput = u128
Source§impl RootAssignRem<u64> for usize
impl RootAssignRem<u64> for usize
Source§fn root_assign_rem(&mut self, exp: u64) -> usize
fn root_assign_rem(&mut self, exp: u64) -> usize
Replaces an integer with the floor of its $n$th root, and returns the remainder (the difference between the original integer and the $n$th power of the floor).
$f(x, n) = x - \lfloor\sqrt[n]{x}\rfloor^n$,
$x \gets \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits():
constant for widths up to 64 bits and for exponents greater than 2, where a
floating-point approximation is refined with $O(1)$ adjustments; 128-bit square
roots (exp == 2) fall back to an $O(n)$ binary search.
§Panics
Panics if exp is zero.
§Examples
See here.