Struct fix::Fix [] [src]

pub struct Fix<Bits, Base, Exp> {
    pub bits: Bits,
    // some fields omitted
}

Fixed-point number representing Bits × Base Exp.

  • Bits is an integer primitive type, or any type which can be created from a type-level integer and exponentiated.
  • Base is an Unsigned type-level integer.
  • Exp is a signed type-level Integer.

Summary of operations

Lower case variables represent values of Bits. Upper case B and E represent type-level integers Base and Exp, respectively.

  • −(x BE) = (−x) BE
  • (x BE) + (y BE) = (x + y) BE
  • (x BE) − (y BE) = (x − y) BE
  • (x BEx) × (y BEy) = (x × y) BEx + Ey
  • (x BEx) ÷ (y BEy) = (x ÷ y) BEx − Ey
  • (x BEx) % (y BEy) = (x % y) BEx
  • (x BE) × y = (x × y) BE
  • (x BE) ÷ y = (x ÷ y) BE
  • (x BE) % y = (x % y) BE

Fields

The underlying integer.

Methods

impl<Bits, Base, Exp> Fix<Bits, Base, Exp>
[src]

[src]

Creates a number.

Examples

use fix::aliases::si::{Kilo, Milli};
Milli::new(25); // 0.025
Kilo::new(25); // 25 000

[src]

Converts to another Exp.

Examples

use fix::aliases::si::{Kilo, Milli};
let kilo = Kilo::new(5);
let milli = Milli::new(5_000_000);
assert_eq!(kilo, milli.convert());
assert_eq!(milli, kilo.convert());

Trait Implementations

impl<Bits, Base, Exp> Copy for Fix<Bits, Base, Exp> where
    Bits: Copy
[src]

impl<Bits, Base, Exp> Clone for Fix<Bits, Base, Exp> where
    Bits: Clone
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<Bits, Base, Exp> Default for Fix<Bits, Base, Exp> where
    Bits: Default
[src]

[src]

Returns the "default value" for a type. Read more

impl<Bits, Base, Exp> Hash for Fix<Bits, Base, Exp> where
    Bits: Hash
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<Bits, Base, Exp> Debug for Fix<Bits, Base, Exp> where
    Bits: Debug,
    Base: Unsigned,
    Exp: Integer
[src]

[src]

Formats the value using the given formatter.

impl<Bits, Base, Exp> Eq for Fix<Bits, Base, Exp> where
    Bits: Eq
[src]

impl<Bits, Base, Exp> PartialEq for Fix<Bits, Base, Exp> where
    Bits: PartialEq
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<Bits, Base, Exp> PartialOrd for Fix<Bits, Base, Exp> where
    Bits: PartialOrd
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<Bits, Base, Exp> Ord for Fix<Bits, Base, Exp> where
    Bits: Ord
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl<Bits, Base, Exp> Neg for Fix<Bits, Base, Exp> where
    Bits: Neg<Output = Bits>, 
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl<Bits, Base, Exp> Add for Fix<Bits, Base, Exp> where
    Bits: Add<Output = Bits>, 
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<Bits, Base, Exp> Sub for Fix<Bits, Base, Exp> where
    Bits: Sub<Output = Bits>, 
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<Bits, Base, LExp, RExp> Mul<Fix<Bits, Base, RExp>> for Fix<Bits, Base, LExp> where
    Bits: Mul<Output = Bits>,
    LExp: Add<RExp>, 
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<Bits, Base, LExp, RExp> Div<Fix<Bits, Base, RExp>> for Fix<Bits, Base, LExp> where
    Bits: Div<Output = Bits>,
    LExp: Sub<RExp>, 
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<Bits, Base, Exp> Rem for Fix<Bits, Base, Exp> where
    Bits: Rem<Output = Bits>, 
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<Bits, Base, Exp> Mul<Bits> for Fix<Bits, Base, Exp> where
    Bits: Mul<Output = Bits>, 
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<Bits, Base, Exp> Div<Bits> for Fix<Bits, Base, Exp> where
    Bits: Div<Output = Bits>, 
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<Bits, Base, Exp> Rem<Bits> for Fix<Bits, Base, Exp> where
    Bits: Rem<Output = Bits>, 
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<Bits, Base, Exp> AddAssign for Fix<Bits, Base, Exp> where
    Bits: AddAssign
[src]

[src]

Performs the += operation.

impl<Bits, Base, Exp> SubAssign for Fix<Bits, Base, Exp> where
    Bits: SubAssign
[src]

[src]

Performs the -= operation.

impl<Bits, Base, Exp> MulAssign<Bits> for Fix<Bits, Base, Exp> where
    Bits: MulAssign
[src]

[src]

Performs the *= operation.

impl<Bits, Base, Exp> DivAssign<Bits> for Fix<Bits, Base, Exp> where
    Bits: DivAssign
[src]

[src]

Performs the /= operation.

impl<Bits, Base, LExp, RExp> RemAssign<Fix<Bits, Base, RExp>> for Fix<Bits, Base, LExp> where
    Bits: RemAssign
[src]

[src]

Performs the %= operation.

impl<Bits, Base, Exp> RemAssign<Bits> for Fix<Bits, Base, Exp> where
    Bits: RemAssign
[src]

[src]

Performs the %= operation.