pub trait RoundToMultipleOfPowerOf2Assign<RHS> {
fn round_to_multiple_of_power_of_2_assign(
&mut self,
pow: RHS,
rm: RoundingMode
);
}Expand description
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
Required Methods§
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: RHS, rm: RoundingMode)
Implementations on Foreign Types§
source§impl RoundToMultipleOfPowerOf2Assign<u64> for u8
impl RoundToMultipleOfPowerOf2Assign<u64> for u8
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for u16
impl RoundToMultipleOfPowerOf2Assign<u64> for u16
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for u32
impl RoundToMultipleOfPowerOf2Assign<u64> for u32
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for u64
impl RoundToMultipleOfPowerOf2Assign<u64> for u64
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for u128
impl RoundToMultipleOfPowerOf2Assign<u64> for u128
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for usize
impl RoundToMultipleOfPowerOf2Assign<u64> for usize
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for i8
impl RoundToMultipleOfPowerOf2Assign<u64> for i8
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for i16
impl RoundToMultipleOfPowerOf2Assign<u64> for i16
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for i32
impl RoundToMultipleOfPowerOf2Assign<u64> for i32
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for i64
impl RoundToMultipleOfPowerOf2Assign<u64> for i64
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for i128
impl RoundToMultipleOfPowerOf2Assign<u64> for i128
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.
source§impl RoundToMultipleOfPowerOf2Assign<u64> for isize
impl RoundToMultipleOfPowerOf2Assign<u64> for isize
source§fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
fn round_to_multiple_of_power_of_2_assign(&mut self, pow: u64, rm: RoundingMode)
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down.
See the RoundToMultipleOfPowerOf2
documentation for details.
The following two expressions are equivalent:
x.round_to_multiple_of_power_of_2_assign(pow, RoundingMode::Exact);assert!(x.divisible_by_power_of_2(pow));
but the latter should be used as it is clearer and more efficient.
Worst-case complexity
Constant time and additional memory.
Panics
- If
rmisExact, butselfis not a multiple of the power of 2. - If
rmisFloor, butselfis negative with a too-large absolute value to round to the next lowest multiple. - If
rmisCeiling, butselfis too large to round to the next highest multiple. - If
rmisUp, butselfhas too large an absolute value to round to the next multiple with a greater absolute value. - If
rmisNearest, but the nearest multiple is outside the representable range.
Examples
See here.