[][src]Struct strength_reduce::StrengthReducedU16

pub struct StrengthReducedU16 { /* 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 StrengthReducedU16[src]

pub fn new(divisor: u16) -> 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: u16, denom: Self) -> (u16, u16)[src]

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

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

Retrieve the value used to create this struct

Trait Implementations

impl Clone for StrengthReducedU16[src]

impl Copy for StrengthReducedU16[src]

impl Debug for StrengthReducedU16[src]

impl Div<StrengthReducedU16> for u16[src]

type Output = u16

The resulting type after applying the / operator.

impl Rem<StrengthReducedU16> for u16[src]

type Output = u16

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.