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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Implementors