[][src]Struct strength_reduce::StrengthReducedU128

pub struct StrengthReducedU128 { /* fields omitted */ }

Implements unsigned division and modulo via mutiplication and shifts.

Creating a an instance of this struct is more expensive than a single division, but if the division is repeated, this version will be several times faster than naive division.

Methods

impl StrengthReducedU128[src]

pub fn new(divisor: u128) -> Self[src]

Creates a new divisor instance.

If possible, avoid calling new() from an inner loop: The intended usage is to create an instance of this struct outside the loop, and use it for divison and remainders inside the loop.

Panics:

Panics if divisor is 0

pub fn div_rem(numerator: u128, denom: Self) -> (u128, u128)[src]

Simultaneous truncated integer division and modulus. Returns (quotient, remainder).

pub fn get(&self) -> u128[src]

Retrieve the value used to create this struct

Trait Implementations

impl Clone for StrengthReducedU128[src]

impl Copy for StrengthReducedU128[src]

impl Debug for StrengthReducedU128[src]

impl Div<StrengthReducedU128> for u128[src]

type Output = u128

The resulting type after applying the / operator.

impl Rem<StrengthReducedU128> for u128[src]

type Output = u128

The resulting type after applying the % operator.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.