Trait malachite_base::num::arithmetic::traits::DivAssignRem
source · [−]pub trait DivAssignRem<RHS = Self> {
type RemOutput;
fn div_assign_rem(&mut self, other: RHS) -> Self::RemOutput;
}
Expand description
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero, and the remainder has the same sign as the dividend (first input).
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
Required Associated Types
Required Methods
fn div_assign_rem(&mut self, other: RHS) -> Self::RemOutput
Implementations on Foreign Types
sourceimpl DivAssignRem<u8> for u8
impl DivAssignRem<u8> for u8
sourcefn div_assign_rem(&mut self, other: u8) -> u8
fn div_assign_rem(&mut self, other: u8) -> u8
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor, $$ $$ x \gets \left \lfloor \frac{x}{y} \right \rfloor. $$
For unsigned integers, div_assign_rem
is equivalent to div_assign_mod
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type RemOutput = u8
sourceimpl DivAssignRem<u16> for u16
impl DivAssignRem<u16> for u16
sourcefn div_assign_rem(&mut self, other: u16) -> u16
fn div_assign_rem(&mut self, other: u16) -> u16
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor, $$ $$ x \gets \left \lfloor \frac{x}{y} \right \rfloor. $$
For unsigned integers, div_assign_rem
is equivalent to div_assign_mod
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type RemOutput = u16
sourceimpl DivAssignRem<u32> for u32
impl DivAssignRem<u32> for u32
sourcefn div_assign_rem(&mut self, other: u32) -> u32
fn div_assign_rem(&mut self, other: u32) -> u32
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor, $$ $$ x \gets \left \lfloor \frac{x}{y} \right \rfloor. $$
For unsigned integers, div_assign_rem
is equivalent to div_assign_mod
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type RemOutput = u32
sourceimpl DivAssignRem<u64> for u64
impl DivAssignRem<u64> for u64
sourcefn div_assign_rem(&mut self, other: u64) -> u64
fn div_assign_rem(&mut self, other: u64) -> u64
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor, $$ $$ x \gets \left \lfloor \frac{x}{y} \right \rfloor. $$
For unsigned integers, div_assign_rem
is equivalent to div_assign_mod
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type RemOutput = u64
sourceimpl DivAssignRem<u128> for u128
impl DivAssignRem<u128> for u128
sourcefn div_assign_rem(&mut self, other: u128) -> u128
fn div_assign_rem(&mut self, other: u128) -> u128
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor, $$ $$ x \gets \left \lfloor \frac{x}{y} \right \rfloor. $$
For unsigned integers, div_assign_rem
is equivalent to div_assign_mod
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type RemOutput = u128
sourceimpl DivAssignRem<usize> for usize
impl DivAssignRem<usize> for usize
sourcefn div_assign_rem(&mut self, other: usize) -> usize
fn div_assign_rem(&mut self, other: usize) -> usize
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = x - y\left \lfloor \frac{x}{y} \right \rfloor, $$ $$ x \gets \left \lfloor \frac{x}{y} \right \rfloor. $$
For unsigned integers, div_assign_rem
is equivalent to div_assign_mod
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type RemOutput = usize
sourceimpl DivAssignRem<i8> for i8
impl DivAssignRem<i8> for i8
sourcefn div_assign_rem(&mut self, other: i8) -> i8
fn div_assign_rem(&mut self, other: i8) -> i8
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero and the remainder has the same sign as the dividend.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = x - y \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor, $$ $$ x \gets \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor. $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0, or if self
is $t::MIN
and other
is -1.
Examples
See here.
type RemOutput = i8
sourceimpl DivAssignRem<i16> for i16
impl DivAssignRem<i16> for i16
sourcefn div_assign_rem(&mut self, other: i16) -> i16
fn div_assign_rem(&mut self, other: i16) -> i16
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero and the remainder has the same sign as the dividend.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = x - y \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor, $$ $$ x \gets \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor. $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0, or if self
is $t::MIN
and other
is -1.
Examples
See here.
type RemOutput = i16
sourceimpl DivAssignRem<i32> for i32
impl DivAssignRem<i32> for i32
sourcefn div_assign_rem(&mut self, other: i32) -> i32
fn div_assign_rem(&mut self, other: i32) -> i32
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero and the remainder has the same sign as the dividend.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = x - y \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor, $$ $$ x \gets \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor. $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0, or if self
is $t::MIN
and other
is -1.
Examples
See here.
type RemOutput = i32
sourceimpl DivAssignRem<i64> for i64
impl DivAssignRem<i64> for i64
sourcefn div_assign_rem(&mut self, other: i64) -> i64
fn div_assign_rem(&mut self, other: i64) -> i64
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero and the remainder has the same sign as the dividend.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = x - y \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor, $$ $$ x \gets \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor. $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0, or if self
is $t::MIN
and other
is -1.
Examples
See here.
type RemOutput = i64
sourceimpl DivAssignRem<i128> for i128
impl DivAssignRem<i128> for i128
sourcefn div_assign_rem(&mut self, other: i128) -> i128
fn div_assign_rem(&mut self, other: i128) -> i128
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero and the remainder has the same sign as the dividend.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = x - y \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor, $$ $$ x \gets \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor. $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0, or if self
is $t::MIN
and other
is -1.
Examples
See here.
type RemOutput = i128
sourceimpl DivAssignRem<isize> for isize
impl DivAssignRem<isize> for isize
sourcefn div_assign_rem(&mut self, other: isize) -> isize
fn div_assign_rem(&mut self, other: isize) -> isize
Divides a number by another number in place, returning the remainder. The quotient is rounded towards zero and the remainder has the same sign as the dividend.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = x - y \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor, $$ $$ x \gets \operatorname{sgn}(xy) \left \lfloor \left | \frac{x}{y} \right | \right \rfloor. $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0, or if self
is $t::MIN
and other
is -1.
Examples
See here.