Trait malachite_base::num::arithmetic::traits::DivMod
source · [−]pub trait DivMod<RHS = Self> {
type DivOutput;
type ModOutput;
fn div_mod(self, other: RHS) -> (Self::DivOutput, Self::ModOutput);
}
Expand description
Divides two numbers, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the divisor (second input).
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
Required Associated Types
Required Methods
Implementations on Foreign Types
sourceimpl DivMod<u8> for u8
impl DivMod<u8> for u8
sourcefn div_mod(self, other: u8) -> (u8, u8)
fn div_mod(self, other: u8) -> (u8, u8)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type DivOutput = u8
type ModOutput = u8
sourceimpl DivMod<u16> for u16
impl DivMod<u16> for u16
sourcefn div_mod(self, other: u16) -> (u16, u16)
fn div_mod(self, other: u16) -> (u16, u16)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type DivOutput = u16
type ModOutput = u16
sourceimpl DivMod<u32> for u32
impl DivMod<u32> for u32
sourcefn div_mod(self, other: u32) -> (u32, u32)
fn div_mod(self, other: u32) -> (u32, u32)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type DivOutput = u32
type ModOutput = u32
sourceimpl DivMod<u64> for u64
impl DivMod<u64> for u64
sourcefn div_mod(self, other: u64) -> (u64, u64)
fn div_mod(self, other: u64) -> (u64, u64)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type DivOutput = u64
type ModOutput = u64
sourceimpl DivMod<u128> for u128
impl DivMod<u128> for u128
sourcefn div_mod(self, other: u128) -> (u128, u128)
fn div_mod(self, other: u128) -> (u128, u128)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type DivOutput = u128
type ModOutput = u128
sourceimpl DivMod<usize> for usize
impl DivMod<usize> for usize
sourcefn div_mod(self, other: usize) -> (usize, usize)
fn div_mod(self, other: usize) -> (usize, usize)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq r < y$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is 0.
Examples
See here.
type DivOutput = usize
type ModOutput = usize
sourceimpl DivMod<i8> for i8
impl DivMod<i8> for i8
sourcefn div_mod(self, other: i8) -> (i8, i8)
fn div_mod(self, other: i8) -> (i8, i8)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
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 DivOutput = i8
type ModOutput = i8
sourceimpl DivMod<i16> for i16
impl DivMod<i16> for i16
sourcefn div_mod(self, other: i16) -> (i16, i16)
fn div_mod(self, other: i16) -> (i16, i16)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
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 DivOutput = i16
type ModOutput = i16
sourceimpl DivMod<i32> for i32
impl DivMod<i32> for i32
sourcefn div_mod(self, other: i32) -> (i32, i32)
fn div_mod(self, other: i32) -> (i32, i32)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
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 DivOutput = i32
type ModOutput = i32
sourceimpl DivMod<i64> for i64
impl DivMod<i64> for i64
sourcefn div_mod(self, other: i64) -> (i64, i64)
fn div_mod(self, other: i64) -> (i64, i64)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
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 DivOutput = i64
type ModOutput = i64
sourceimpl DivMod<i128> for i128
impl DivMod<i128> for i128
sourcefn div_mod(self, other: i128) -> (i128, i128)
fn div_mod(self, other: i128) -> (i128, i128)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
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 DivOutput = i128
type ModOutput = i128
sourceimpl DivMod<isize> for isize
impl DivMod<isize> for isize
sourcefn div_mod(self, other: isize) -> (isize, isize)
fn div_mod(self, other: isize) -> (isize, isize)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards negative infinity, and the remainder has the same sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lfloor \frac{x}{y} \right \rfloor, \space x - y\left \lfloor \frac{x}{y} \right \rfloor \right ). $$
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.