Trait malachite_base::num::arithmetic::traits::RoundToMultipleAssign
source · [−]pub trait RoundToMultipleAssign<RHS = Self> {
fn round_to_multiple_assign(&mut self, other: RHS, rm: RoundingMode);
}
Expand description
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
Required Methods
fn round_to_multiple_assign(&mut self, other: RHS, rm: RoundingMode)
Implementations on Foreign Types
sourceimpl RoundToMultipleAssign<u8> for u8
impl RoundToMultipleAssign<u8> for u8
sourcefn round_to_multiple_assign(&mut self, other: u8, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: u8, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding modes that are guaranteed to return without a panic are Down
and Floor
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<u16> for u16
impl RoundToMultipleAssign<u16> for u16
sourcefn round_to_multiple_assign(&mut self, other: u16, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: u16, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding modes that are guaranteed to return without a panic are Down
and Floor
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<u32> for u32
impl RoundToMultipleAssign<u32> for u32
sourcefn round_to_multiple_assign(&mut self, other: u32, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: u32, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding modes that are guaranteed to return without a panic are Down
and Floor
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<u64> for u64
impl RoundToMultipleAssign<u64> for u64
sourcefn round_to_multiple_assign(&mut self, other: u64, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: u64, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding modes that are guaranteed to return without a panic are Down
and Floor
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<u128> for u128
impl RoundToMultipleAssign<u128> for u128
sourcefn round_to_multiple_assign(&mut self, other: u128, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: u128, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding modes that are guaranteed to return without a panic are Down
and Floor
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<usize> for usize
impl RoundToMultipleAssign<usize> for usize
sourcefn round_to_multiple_assign(&mut self, other: usize, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: usize, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding modes that are guaranteed to return without a panic are Down
and Floor
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<i8> for i8
impl RoundToMultipleAssign<i8> for i8
sourcefn round_to_multiple_assign(&mut self, other: i8, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: i8, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<i16> for i16
impl RoundToMultipleAssign<i16> for i16
sourcefn round_to_multiple_assign(&mut self, other: i16, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: i16, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<i32> for i32
impl RoundToMultipleAssign<i32> for i32
sourcefn round_to_multiple_assign(&mut self, other: i32, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: i32, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<i64> for i64
impl RoundToMultipleAssign<i64> for i64
sourcefn round_to_multiple_assign(&mut self, other: i64, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: i64, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<i128> for i128
impl RoundToMultipleAssign<i128> for i128
sourcefn round_to_multiple_assign(&mut self, other: i128, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: i128, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.
sourceimpl RoundToMultipleAssign<isize> for isize
impl RoundToMultipleAssign<isize> for isize
sourcefn round_to_multiple_assign(&mut self, other: isize, rm: RoundingMode)
fn round_to_multiple_assign(&mut self, other: isize, rm: RoundingMode)
Rounds a number to a multiple of another number in place, according to a specified rounding mode.
The only rounding mode that is guaranteed to return without a panic is Down
.
See the RoundToMultiple
documentation for
details.
The following two expressions are equivalent:
x.round_to_multiple_assign(other, RoundingMode::Exact);
assert!(x.divisible_by(other));
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 ofother
. - If the multiple is outside the representable range.
- If
self
is nonzero,other
is zero, andrm
is trying to round away from zero.
Examples
See here.