Fix

Struct Fix 

Source
pub struct Fix<R, B, E>
where R: Radix<B>,
{ /* private fields */ }
Expand description

Fixed-point number representing _ Radix Digits × Radix Exponent_.

  • Radix is a type-level integer which represents the base of number.
    • Unsigned (U*) number means unsigned type.
    • Integer (P*) number means signed type.
  • Digits is a signed positive type-level Integer which represent width of mantissa in digits of specified radix.
  • Exponent is a signed type-level Integer.

§Summary of operations

Lower case variables represent values of mantissa. Upper case R, B and E represent type-level integers Radix, Digits and Exponent, respectively.

§Arithmetic

TODO: Update outdated docs

  • −(x BE) = (−x) BE

  • (xMx BEx) + (yMy BEy) = (x + y)max Mx My Bmin Ex Ey

  • (xMx BEx) - (yMy BEy) = (x - y)max Mx My Bmin Ex Ey

  • (xMx BEx) × (yMy BEy) = (x × y)Mx + My BEx + Ey

  • (xMx BEx) ÷ (yMy BEy) = (x ÷ y)Mx - My BEx − Ey

  • (x BEx) % (y BEy) = (x % y) BEx

§Comparison

To compare fixed-point values of different types you should first cast at least one of its to type of other or cast both to single common type. Implicit semi-automatic conversion lacks because in common case it may give ambiguous results.

Implementations§

Source§

impl<R, B, E> Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent,

Source

pub const MIN: Self

Minimum value

Source

pub const MAX: Self

Maximum value

Source

pub const fn new(bits: R::Type) -> Self

Create a number from raw value.

§Examples
use typenum::P2;
use ufix::si::{Kilo, Milli};

Milli::<P2>::new(25); // 0.025
Kilo::<P2>::new(25); // 25 000
Source

pub const fn into_inner(self) -> R::Type

Get raw value of a number.

Source

pub fn convert<Br, Er>(self) -> Fix<R, Br, Er>
where R: Radix<Br>, Er: Exponent, Br: Digits, Mantissa<R, Br>: Cast<Mantissa<R, B>>,

Converts to another Bits and/or Exp.

§Examples
use typenum::{P1, P7};
use ufix::si::{Kilo, Milli};

let kilo = Kilo::<P1>::new(5);
let milli = Milli::<P7>::new(5_000_000);

assert_eq!(kilo, milli.convert());
assert_eq!(milli, kilo.convert());
Source

pub fn try_convert<Br, Er>(self) -> Result<Fix<R, Br, Er>>
where R: Radix<Br>, Er: Exponent, Br: Digits, Mantissa<R, Br>: TryCast<Mantissa<R, B>>,

Converts to another Bits and/or Exp.

§Examples
use typenum::{P1, P7};
use ufix::si::{Kilo, Milli};

let kilo = Kilo::<P1>::new(5);
let milli = Milli::<P7>::new(5_000_000);

assert_eq!(kilo, milli.convert());
assert_eq!(milli, kilo.convert());

Trait Implementations§

Source§

impl<R, B1, E1, B2, E2> Add<Fix<R, B2, E2>> for Fix<R, B1, E1>
where R: Radix<B1> + Radix<B2> + Radix<<Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output>, B1: Digits + Add<E1>, E1: Exponent + Min<E2>, B2: Digits + Add<E2>, E2: Exponent, Sum<B1, E1>: Max<Sum<B2, E2>>, Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>>: Add1, <Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output: Digits, Minimum<E1, E2>: Exponent, Maximum<Sum<B1, E1>, Sum<B2, E2>>: Sub<Minimum<E1, E2>>, Mantissa<R, <Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output>: Cast<Mantissa<R, B1>> + Cast<Mantissa<R, B2>> + Add<Output = Mantissa<R, <Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output>>,

Fixed-point addition

Fix<R, B1, E1> + Fix<R, B2, E2> = Fix<R, max(B1 + E1, B2 + E2) - min(E1, E2), min(E1, E2)>

BFix<32, -16> (Q16.16) + BFix<32, -24> (Q8.24) = BFix<40, -24> (Q40.24) BFix<32, 16> + BFix<32, 8> = BFix<40, 8>

Source§

type Output = Fix<R, <<<<B1 as Add<E1>>::Output as Max<<B2 as Add<E2>>::Output>>::Output as Sub<<E1 as Min<E2>>::Output>>::Output as Add<PInt<UInt<UTerm, B1>>>>::Output, <E1 as Min<E2>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, other: Fix<R, B2, E2>) -> Self::Output

Performs the + operation. Read more
Source§

impl<R, B, E, T> AddAssign<T> for Fix<R, B, E>
where R: Radix<B>, Mantissa<R, B>: AddAssign, Fix<R, B, E>: Cast<T>,

Source§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
Source§

impl<R, B, Br, E, Er> Cast<Fix<R, B, E>> for Fix<R, Br, Er>
where R: Radix<B> + Radix<Br>, B: Digits, E: Exponent, Br: Digits, Er: Exponent, Mantissa<R, Br>: Cast<Mantissa<R, B>>,

Source§

fn cast(value: Fix<R, B, E>) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for f32
where R: Radix<B>, B: Digits, E: Exponent, f32: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> f32

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for f64
where R: Radix<B>, B: Digits, E: Exponent, f64: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> f64

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for i16
where R: Radix<B>, B: Digits, E: Exponent, i16: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> i16

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for i32
where R: Radix<B>, B: Digits, E: Exponent, i32: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> i32

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for i64
where R: Radix<B>, B: Digits, E: Exponent, i64: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> i64

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for i8
where R: Radix<B>, B: Digits, E: Exponent, i8: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> i8

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for u16
where R: Radix<B>, B: Digits, E: Exponent, u16: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> u16

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for u32
where R: Radix<B>, B: Digits, E: Exponent, u32: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> u32

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for u64
where R: Radix<B>, B: Digits, E: Exponent, u64: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> u64

Convert value from T
Source§

impl<R, B, E> Cast<Fix<R, B, E>> for u8
where R: Radix<B>, B: Digits, E: Exponent, u8: Cast<Mantissa<R, B>>,

Source§

fn cast(_: Fix<R, B, E>) -> u8

Convert value from T
Source§

impl<R, B, E> Cast<f32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, f32: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<f32>,

Source§

fn cast(value: f32) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<f64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, f64: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<f64>,

Source§

fn cast(value: f64) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<i16> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i16: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i16>,

Source§

fn cast(value: i16) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<i32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i32: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i32>,

Source§

fn cast(value: i32) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<i64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i64: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i64>,

Source§

fn cast(value: i64) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<i8> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i8: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i8>,

Source§

fn cast(value: i8) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<u16> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u16: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u16>,

Source§

fn cast(value: u16) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<u32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u32: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u32>,

Source§

fn cast(value: u32) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<u64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u64: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u64>,

Source§

fn cast(value: u64) -> Self

Convert value from T
Source§

impl<R, B, E> Cast<u8> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u8: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u8>,

Source§

fn cast(value: u8) -> Self

Convert value from T
Source§

impl<R, B: Clone, E: Clone> Clone for Fix<R, B, E>
where R: Radix<B> + Clone, R::Type: Clone,

Source§

fn clone(&self) -> Fix<R, B, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R, B, E> Debug for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<R, B: Default, E: Default> Default for Fix<R, B, E>
where R: Radix<B> + Default, R::Type: Default,

Source§

fn default() -> Fix<R, B, E>

Returns the “default value” for a type. Read more
Source§

impl<R, B1, E1, B2, E2> Div<Fix<R, B2, E2>> for Fix<R, B1, E1>
where R: Radix<B1> + Radix<B2> + Radix<Diff<B1, B2>>, B1: Digits + Sub<B2>, E1: Exponent + Sub<E2>, B2: Digits, E2: Exponent, Diff<B1, B2>: Digits, Diff<E1, E2>: Exponent, Mantissa<R, Diff<B1, B2>>: Cast<Mantissa<R, B1>>, Mantissa<R, B1>: Cast<Mantissa<R, B2>> + Div<Output = Mantissa<R, B1>>,

Fixed-point division

Fix<R, B1, E1> / Fix<R, B2, E2> = Fix<R, B1 - B2, Base, E1 - E2>

Source§

type Output = Fix<R, <B1 as Sub<B2>>::Output, <E1 as Sub<E2>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, other: Fix<R, B2, E2>) -> Self::Output

Performs the / operation. Read more
Source§

impl<R, B, E, T> DivAssign<T> for Fix<R, B, E>
where R: Radix<B>, Mantissa<R, B>: DivAssign<T>,

Source§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
Source§

impl<R, B, E> From<Fix<R, B, E>> for f32
where R: Radix<B>, B: Digits, E: Exponent, f32: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for f64
where R: Radix<B>, B: Digits, E: Exponent, f64: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for i16
where R: Radix<B>, B: Digits, E: Exponent, i16: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for i32
where R: Radix<B>, B: Digits, E: Exponent, i32: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for i64
where R: Radix<B>, B: Digits, E: Exponent, i64: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for i8
where R: Radix<B>, B: Digits, E: Exponent, i8: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for u16
where R: Radix<B>, B: Digits, E: Exponent, u16: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for u32
where R: Radix<B>, B: Digits, E: Exponent, u32: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for u64
where R: Radix<B>, B: Digits, E: Exponent, u64: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<Fix<R, B, E>> for u8
where R: Radix<B>, B: Digits, E: Exponent, u8: Cast<Mantissa<R, B>>,

Source§

fn from(_: Fix<R, B, E>) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<f32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, f32: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<f32>,

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<f64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, f64: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<f64>,

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<i16> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i16: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i16>,

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<i32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i32: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i32>,

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<i64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i64: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i64>,

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<i8> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i8: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<i8>,

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<u16> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u16: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u16>,

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<u32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u32: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u32>,

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<u64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u64: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u64>,

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> From<u8> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u8: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<u8>,

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl<R, B, E> Hash for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<R, B1, E1, B2, E2> Mul<Fix<R, B2, E2>> for Fix<R, B1, E1>
where R: Radix<B1> + Radix<B2> + Radix<Sum<B1, B2>>, B1: Digits + Add<B2>, E1: Exponent + Add<E2>, B2: Digits, E2: Exponent, Sum<B1, B2>: Digits, Sum<E1, E2>: Exponent, Mantissa<R, Sum<B1, B2>>: Cast<Mantissa<R, B1>> + Cast<Mantissa<R, B2>> + Mul<Output = Mantissa<R, Sum<B1, B2>>>,

Fixed-point multiplication

Fix<R, B1, E1> * Fix<R, B2, E2> = Fix<R, B1 + B2, E1 + E2>

Source§

type Output = Fix<R, <B1 as Add<B2>>::Output, <E1 as Add<E2>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Fix<R, B2, E2>) -> Self::Output

Performs the * operation. Read more
Source§

impl<R, B, E, T> MulAssign<T> for Fix<R, B, E>
where R: Radix<B>, Mantissa<R, B>: MulAssign<T>,

Source§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
Source§

impl<R, B, E> Neg for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: Neg<Output = Mantissa<R, B>>,

Source§

type Output = Fix<R, B, E>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<R, B, E> Ord for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<R, B, E> PartialEq for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<R, B, E> PartialOrd for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: PartialOrd,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<R, B, E> Rem for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: Rem<Output = Mantissa<R, B>>,

Fixed-point reminder

Source§

type Output = Fix<R, B, E>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self

Performs the % operation. Read more
Source§

impl<R, B, E1, E2> RemAssign<Fix<R, B, E2>> for Fix<R, B, E1>
where R: Radix<B>, Mantissa<R, B>: RemAssign,

Source§

fn rem_assign(&mut self, other: Fix<R, B, E2>)

Performs the %= operation. Read more
Source§

impl<R, B1, E1, B2, E2> Sub<Fix<R, B2, E2>> for Fix<R, B1, E1>
where R: Radix<B1> + Radix<B2> + Radix<<Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output>, B1: Digits + Add<E1>, E1: Exponent + Min<E2>, B2: Digits + Add<E2>, E2: Exponent, Sum<B1, E1>: Max<Sum<B2, E2>>, Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>>: Add1, <Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output: Digits, Minimum<E1, E2>: Exponent, Maximum<Sum<B1, E1>, Sum<B2, E2>>: Sub<Minimum<E1, E2>>, Mantissa<R, <Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output>: Cast<Mantissa<R, B1>> + Cast<Mantissa<R, B2>> + Sub<Output = Mantissa<R, <Diff<Maximum<Sum<B1, E1>, Sum<B2, E2>>, Minimum<E1, E2>> as Add<P1>>::Output>>,

Fixed-point substraction

Fix<R, B1, E1> - Fix<R, B2, E2> = Fix<R, max(B1 + E1, B2 + E2) - min(E1, E2), min(E1, E2)>

Source§

type Output = Fix<R, <<<<B1 as Add<E1>>::Output as Max<<B2 as Add<E2>>::Output>>::Output as Sub<<E1 as Min<E2>>::Output>>::Output as Add<PInt<UInt<UTerm, B1>>>>::Output, <E1 as Min<E2>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Fix<R, B2, E2>) -> Self::Output

Performs the - operation. Read more
Source§

impl<R, B, E, T> SubAssign<T> for Fix<R, B, E>
where R: Radix<B>, Mantissa<R, B>: SubAssign, Fix<R, B, E>: Cast<T>,

Source§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
Source§

impl<R, B, Br, E, Er> TryCast<Fix<R, B, E>> for Fix<R, Br, Er>
where R: Radix<B> + Radix<Br>, B: Digits, E: Exponent, Br: Digits, Er: Exponent, Mantissa<R, Br>: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(value: Fix<R, B, E>) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for f32
where R: Radix<B>, B: Digits, E: Exponent, f32: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<f32>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for f64
where R: Radix<B>, B: Digits, E: Exponent, f64: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<f64>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for i16
where R: Radix<B>, B: Digits, E: Exponent, i16: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<i16>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for i32
where R: Radix<B>, B: Digits, E: Exponent, i32: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<i32>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for i64
where R: Radix<B>, B: Digits, E: Exponent, i64: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<i64>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for i8
where R: Radix<B>, B: Digits, E: Exponent, i8: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<i8>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for u16
where R: Radix<B>, B: Digits, E: Exponent, u16: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<u16>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for u32
where R: Radix<B>, B: Digits, E: Exponent, u32: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<u32>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for u64
where R: Radix<B>, B: Digits, E: Exponent, u64: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<u64>

Convert value from T
Source§

impl<R, B, E> TryCast<Fix<R, B, E>> for u8
where R: Radix<B>, B: Digits, E: Exponent, u8: TryCast<Mantissa<R, B>>,

Source§

fn try_cast(_: Fix<R, B, E>) -> Result<u8>

Convert value from T
Source§

impl<R, B, E> TryCast<f32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, f32: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<f32>,

Source§

fn try_cast(value: f32) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<f64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, f64: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<f64>,

Source§

fn try_cast(value: f64) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<i16> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i16: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<i16>,

Source§

fn try_cast(value: i16) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<i32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i32: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<i32>,

Source§

fn try_cast(value: i32) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<i64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i64: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<i64>,

Source§

fn try_cast(value: i64) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<i8> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, i8: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<i8>,

Source§

fn try_cast(value: i8) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<u16> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u16: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<u16>,

Source§

fn try_cast(value: u16) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<u32> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u32: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<u32>,

Source§

fn try_cast(value: u32) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<u64> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u64: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<u64>,

Source§

fn try_cast(value: u64) -> Result<Self>

Convert value from T
Source§

impl<R, B, E> TryCast<u8> for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, u8: TryCast<Mantissa<R, B>>, Mantissa<R, B>: TryCast<u8>,

Source§

fn try_cast(value: u8) -> Result<Self>

Convert value from T
Source§

impl<R, B: Copy, E: Copy> Copy for Fix<R, B, E>
where R: Radix<B> + Copy, R::Type: Copy,

Source§

impl<R, B, E> Eq for Fix<R, B, E>
where R: Radix<B>, B: Digits, E: Exponent, Mantissa<R, B>: PartialEq,

Auto Trait Implementations§

§

impl<R, B, E> Freeze for Fix<R, B, E>
where <R as Radix<B>>::Type: Freeze,

§

impl<R, B, E> RefUnwindSafe for Fix<R, B, E>
where <R as Radix<B>>::Type: RefUnwindSafe, E: RefUnwindSafe,

§

impl<R, B, E> Send for Fix<R, B, E>
where <R as Radix<B>>::Type: Send, E: Send,

§

impl<R, B, E> Sync for Fix<R, B, E>
where <R as Radix<B>>::Type: Sync, E: Sync,

§

impl<R, B, E> Unpin for Fix<R, B, E>
where <R as Radix<B>>::Type: Unpin, E: Unpin,

§

impl<R, B, E> UnwindSafe for Fix<R, B, E>
where <R as Radix<B>>::Type: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.