Trait malachite_base::num::arithmetic::traits::DivExact
source · [−]Expand description
Divides two numbers, assuming the first exactly divides the second.
If it doesn’t, the div_exact
function may panic or return a meaningless result.
Required Associated Types
Required Methods
Implementations on Foreign Types
sourceimpl DivExact<u8> for u8
impl DivExact<u8> for u8
sourcefn div_exact(self, other: u8) -> u8
fn div_exact(self, other: u8) -> u8
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = u8
sourceimpl DivExact<u16> for u16
impl DivExact<u16> for u16
sourcefn div_exact(self, other: u16) -> u16
fn div_exact(self, other: u16) -> u16
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = u16
sourceimpl DivExact<u32> for u32
impl DivExact<u32> for u32
sourcefn div_exact(self, other: u32) -> u32
fn div_exact(self, other: u32) -> u32
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = u32
sourceimpl DivExact<u64> for u64
impl DivExact<u64> for u64
sourcefn div_exact(self, other: u64) -> u64
fn div_exact(self, other: u64) -> u64
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = u64
sourceimpl DivExact<u128> for u128
impl DivExact<u128> for u128
sourcefn div_exact(self, other: u128) -> u128
fn div_exact(self, other: u128) -> u128
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = u128
sourceimpl DivExact<usize> for usize
impl DivExact<usize> for usize
sourcefn div_exact(self, other: usize) -> usize
fn div_exact(self, other: usize) -> usize
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = usize
sourceimpl DivExact<i8> for i8
impl DivExact<i8> for i8
sourcefn div_exact(self, other: i8) -> i8
fn div_exact(self, other: i8) -> i8
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = i8
sourceimpl DivExact<i16> for i16
impl DivExact<i16> for i16
sourcefn div_exact(self, other: i16) -> i16
fn div_exact(self, other: i16) -> i16
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = i16
sourceimpl DivExact<i32> for i32
impl DivExact<i32> for i32
sourcefn div_exact(self, other: i32) -> i32
fn div_exact(self, other: i32) -> i32
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = i32
sourceimpl DivExact<i64> for i64
impl DivExact<i64> for i64
sourcefn div_exact(self, other: i64) -> i64
fn div_exact(self, other: i64) -> i64
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = i64
sourceimpl DivExact<i128> for i128
impl DivExact<i128> for i128
sourcefn div_exact(self, other: i128) -> i128
fn div_exact(self, other: i128) -> i128
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.
type Output = i128
sourceimpl DivExact<isize> for isize
impl DivExact<isize> for isize
sourcefn div_exact(self, other: isize) -> isize
fn div_exact(self, other: isize) -> isize
Divides a value by another value. The first value must be exactly divisible by the second.
If self
is not exactly divisible by other
, this function may panic or return a
meaningless result.
$$ f(x, y) = \frac{x}{y}. $$
If you are unsure whether the division will be exact, use self / other
instead.
If you’re unsure and you want to know, use self.div_mod(other)
and check whether
the remainder is zero. If you want a function that panics if the division is not
exact, use self.div_round(other, RoundingMode::Exact)
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if other
is zero or if self
is Self::MIN
and other is -1.
Examples
See here.