pub trait RoundToMultipleOfPowerOf2Assign<RHS> {
// Required method
fn round_to_multiple_of_power_of_2_assign(
&mut self,
pow: RHS,
rm: RoundingMode,
) -> Ordering;
}
Expand description
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding mode. An
Ordering
is returned, indicating whether the returned value is less than, equal to, or
greater than the original value.
Required Methods§
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: RHS, rm: RoundingMode, ) -> Ordering
Implementations on Foreign Types§
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.
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,
) -> Ordering
fn round_to_multiple_of_power_of_2_assign( &mut self, pow: u64, rm: RoundingMode, ) -> Ordering
Rounds a number to a multiple of $2^k$ in place, according to a specified rounding
mode. An Ordering
is returned, indicating whether the returned value is less
than, equal to, or greater than the original value.
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, 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.