Trait malachite_base::num::arithmetic::traits::CeilingDivMod
source · [−]pub trait CeilingDivMod<RHS = Self> {
type DivOutput;
type ModOutput;
fn ceiling_div_mod(self, other: RHS) -> (Self::DivOutput, Self::ModOutput);
}
Expand description
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite 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 CeilingDivMod<i8> for i8
impl CeilingDivMod<i8> for i8
sourcefn ceiling_div_mod(self, other: i8) -> (i8, i8)
fn ceiling_div_mod(self, other: i8) -> (i8, i8)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lceil \frac{x}{y} \right \rceil, \space x - y\left \lceil \frac{x}{y} \right \rceil \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 CeilingDivMod<i16> for i16
impl CeilingDivMod<i16> for i16
sourcefn ceiling_div_mod(self, other: i16) -> (i16, i16)
fn ceiling_div_mod(self, other: i16) -> (i16, i16)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lceil \frac{x}{y} \right \rceil, \space x - y\left \lceil \frac{x}{y} \right \rceil \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 CeilingDivMod<i32> for i32
impl CeilingDivMod<i32> for i32
sourcefn ceiling_div_mod(self, other: i32) -> (i32, i32)
fn ceiling_div_mod(self, other: i32) -> (i32, i32)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lceil \frac{x}{y} \right \rceil, \space x - y\left \lceil \frac{x}{y} \right \rceil \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 CeilingDivMod<i64> for i64
impl CeilingDivMod<i64> for i64
sourcefn ceiling_div_mod(self, other: i64) -> (i64, i64)
fn ceiling_div_mod(self, other: i64) -> (i64, i64)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lceil \frac{x}{y} \right \rceil, \space x - y\left \lceil \frac{x}{y} \right \rceil \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 CeilingDivMod<i128> for i128
impl CeilingDivMod<i128> for i128
sourcefn ceiling_div_mod(self, other: i128) -> (i128, i128)
fn ceiling_div_mod(self, other: i128) -> (i128, i128)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lceil \frac{x}{y} \right \rceil, \space x - y\left \lceil \frac{x}{y} \right \rceil \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 CeilingDivMod<isize> for isize
impl CeilingDivMod<isize> for isize
sourcefn ceiling_div_mod(self, other: isize) -> (isize, isize)
fn ceiling_div_mod(self, other: isize) -> (isize, isize)
Divides a number by another number, returning the quotient and remainder. The quotient is rounded towards positive infinity and the remainder has the opposite sign as the second number.
The quotient and remainder satisfy $x = qy + r$ and $0 \leq |r| < |y|$.
$$ f(x, y) = \left ( \left \lceil \frac{x}{y} \right \rceil, \space x - y\left \lceil \frac{x}{y} \right \rceil \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.