Trait malachite_base::num::arithmetic::traits::DivAssignRem

source ·
pub trait DivAssignRem<RHS = Self> {
    type RemOutput;

    // Required method
    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§

source

fn div_assign_rem(&mut self, other: RHS) -> Self::RemOutput

Implementations on Foreign Types§

source§

impl DivAssignRem for i8

source§

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

source§

impl DivAssignRem for i16

source§

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

source§

impl DivAssignRem for i32

source§

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

source§

impl DivAssignRem for i64

source§

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

source§

impl DivAssignRem for i128

source§

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

source§

impl DivAssignRem for isize

source§

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.

§

type RemOutput = isize

source§

impl DivAssignRem for u8

source§

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

source§

impl DivAssignRem for u16

source§

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

source§

impl DivAssignRem for u32

source§

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

source§

impl DivAssignRem for u64

source§

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

source§

impl DivAssignRem for u128

source§

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

source§

impl DivAssignRem for usize

source§

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

Implementors§