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
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for u8
impl RoundToMultipleOfPowerOf2Assign<u64> for u8
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for u16
impl RoundToMultipleOfPowerOf2Assign<u64> for u16
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for u32
impl RoundToMultipleOfPowerOf2Assign<u64> for u32
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for u64
impl RoundToMultipleOfPowerOf2Assign<u64> for u64
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for u128
impl RoundToMultipleOfPowerOf2Assign<u64> for u128
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for usize
impl RoundToMultipleOfPowerOf2Assign<u64> for usize
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for i8
impl RoundToMultipleOfPowerOf2Assign<u64> for i8
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for i16
impl RoundToMultipleOfPowerOf2Assign<u64> for i16
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for i32
impl RoundToMultipleOfPowerOf2Assign<u64> for i32
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for i64
impl RoundToMultipleOfPowerOf2Assign<u64> for i64
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for i128
impl RoundToMultipleOfPowerOf2Assign<u64> for i128
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.
sourceimpl RoundToMultipleOfPowerOf2Assign<u64> for isize
impl RoundToMultipleOfPowerOf2Assign<u64> for isize
sourcefn 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
rm
isExact
, butself
is not a multiple of the power of 2. - If
rm
isFloor
, butself
is negative with a too-large absolute value to round to the next lowest multiple. - If
rm
isCeiling
, butself
is too large to round to the next highest multiple. - If
rm
isUp
, butself
has too large an absolute value to round to the next multiple with a greater absolute value. - If
rm
isNearest
, but the nearest multiple is outside the representable range.
Examples
See here.