Q

Struct Q 

Source
#[repr(transparent)]
pub struct Q<T, A, const F: i8> { pub inner: T, /* private fields */ }
Expand description

Fixed point integer

Generics:

  • T: Base integer
  • A: Accumulator for intermediate results
  • F: Number of fractional bits right of the decimal point

F negative is supported analogously.

  • Q32<31> is (-1..1).step_by(2^-31)
  • Q<i16, _, 20> is (-1/32..1/32).step_by(2^-20)
  • Q<u8, _, 4> is (0..16).step_by(1/16)
  • Q<u8, _, -2> is (0..1024).step_by(4)
assert_eq!(Q8::<4>::from_int(3), Q8::new(3 << 4));
assert_eq!(7 * Q8::<4>::from_f32(1.5), 10);
assert_eq!(7 / Q8::<4>::from_f32(1.5), 4);

Fields§

§inner: T

The inner value representation

Implementations§

Source§

impl<T, A, const F: i8> Q<T, A, F>

Source

pub const DELTA: f32

Step between distinct numbers

assert_eq!(Q32::<31>::DELTA, 2f32.powi(-31));
assert_eq!(Q32::<-4>::DELTA, 2f32.powi(4));
Source

pub const fn new(inner: T) -> Self

Create a new fixed point number from a given representation

assert_eq!(P8::<9>::new(3).inner, 3);
Source§

impl<T: Shift, A, const F: i8> Q<T, A, F>

Source

pub fn scale<const F1: i8>(self) -> Q<T, A, F1>

Convert to a different number of fractional bits (truncating)

Use this liberally for Add/Sub/Rem with Q’s of different F.

assert_eq!(Q8::<4>::new(32).scale::<0>(), Q8::new(2));
Source

pub fn trunc(self) -> T

Return the integer part

assert_eq!(Q8::<4>::new(0x35).trunc(), 0x3);
Source

pub fn from_int(value: T) -> Self

Scale from integer base type

assert_eq!(Q8::<4>::from_int(7).inner, 7 << 4);
Source§

impl<A: Shift, T: Accu<A>, const F: i8> Q<A, T, F>

Source

pub fn quantize(self) -> T

Scale from integer accu type

let q = Q8::<4>::from_f32(0.25);
assert_eq!((q * 7).quantize(), (7.0 * 0.25f32).floor() as _);
Source§

impl<T, A, const F: i8> Q<T, A, F>
where f32: AsPrimitive<Q<T, A, F>>, Self: Copy + 'static,

Source

pub fn from_f32(value: f32) -> Self

Quantize a f32

Source§

impl<T, A, const F: i8> Q<T, A, F>
where f64: AsPrimitive<Q<T, A, F>>, Self: Copy + 'static,

Source

pub fn from_f64(value: f64) -> Self

Quantize a f64

Source§

impl<T, A, const F: i8> Q<T, A, F>
where Self: 'static + Copy + AsPrimitive<f32>,

Source

pub fn as_f32(self) -> f32

Convert lossy to f32

Source§

impl<T, A, const F: i8> Q<T, A, F>
where Self: 'static + Copy + AsPrimitive<f64>,

Source

pub fn as_f64(self) -> f64

Convert lossy to f64

Trait Implementations§

Source§

impl<T: Add<T, Output = T>, A, const F: i8> Add for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: AddAssign<T>, A, const F: i8> AddAssign for Q<T, A, F>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T, A, const F: i8> AsPrimitive<Q<T, A, F>> for Q<T, A, F>
where Self: Copy + 'static,

Source§

fn as_(self) -> Self

Convert a value to another, using the as operator.
Source§

impl<T: 'static + Copy, A: 'static, const F: i8> AsPrimitive<Q<T, A, F>> for f32
where f32: AsPrimitive<T>,

Source§

fn as_(self) -> Q<T, A, F>

Convert a value to another, using the as operator.
Source§

impl<T: 'static + Copy, A: 'static, const F: i8> AsPrimitive<Q<T, A, F>> for f64
where f64: AsPrimitive<T>,

Source§

fn as_(self) -> Q<T, A, F>

Convert a value to another, using the as operator.
Source§

impl<const F: i8> AsPrimitive<Wrapping<i16>> for Q<Wrapping<i32>, Wrapping<i16>, F>

Source§

fn as_(self) -> Wrapping<i16>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<i32>> for Q<Wrapping<i64>, Wrapping<i32>, F>

Source§

fn as_(self) -> Wrapping<i32>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<i64>> for Q<Wrapping<i128>, Wrapping<i64>, F>

Source§

fn as_(self) -> Wrapping<i64>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<i8>> for Q<Wrapping<i16>, Wrapping<i8>, F>

Source§

fn as_(self) -> Wrapping<i8>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<u16>> for Q<Wrapping<u32>, Wrapping<u16>, F>

Source§

fn as_(self) -> Wrapping<u16>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<u32>> for Q<Wrapping<u64>, Wrapping<u32>, F>

Source§

fn as_(self) -> Wrapping<u32>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<u64>> for Q<Wrapping<u128>, Wrapping<u64>, F>

Source§

fn as_(self) -> Wrapping<u64>

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<Wrapping<u8>> for Q<Wrapping<u16>, Wrapping<u8>, F>

Source§

fn as_(self) -> Wrapping<u8>

Scale from integer accu type

Source§

impl<T: AsPrimitive<f32>, A: 'static, const F: i8> AsPrimitive<f32> for Q<T, A, F>

Source§

fn as_(self) -> f32

Convert a value to another, using the as operator.
Source§

impl<T: AsPrimitive<f64>, A: 'static, const F: i8> AsPrimitive<f64> for Q<T, A, F>

Source§

fn as_(self) -> f64

Convert a value to another, using the as operator.
Source§

impl<const F: i8> AsPrimitive<i16> for Q<i32, i16, F>

Source§

fn as_(self) -> i16

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<i32> for Q<i64, i32, F>

Source§

fn as_(self) -> i32

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<i64> for Q<i128, i64, F>

Source§

fn as_(self) -> i64

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<i8> for Q<i16, i8, F>

Source§

fn as_(self) -> i8

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<u16> for Q<u32, u16, F>

Source§

fn as_(self) -> u16

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<u32> for Q<u64, u32, F>

Source§

fn as_(self) -> u32

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<u64> for Q<u128, u64, F>

Source§

fn as_(self) -> u64

Scale from integer accu type

Source§

impl<const F: i8> AsPrimitive<u8> for Q<u16, u8, F>

Source§

fn as_(self) -> u8

Scale from integer accu type

Source§

impl<T: Binary, A, const F: i8> Binary for Q<T, A, F>

Source§

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

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

impl<T: BitAnd<T, Output = T>, A, const F: i8> BitAnd for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<T: BitAndAssign<T>, A, const F: i8> BitAndAssign for Q<T, A, F>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<T: BitOr<T, Output = T>, A, const F: i8> BitOr for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<T: BitOrAssign<T>, A, const F: i8> BitOrAssign for Q<T, A, F>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<T: BitXor<T, Output = T>, A, const F: i8> BitXor for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T: BitXorAssign<T>, A, const F: i8> BitXorAssign for Q<T, A, F>

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<T: Clone, A, const F: i8> Clone for Q<T, A, F>

Source§

fn clone(&self) -> Self

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<const F: i8> ConstOne for Q<Wrapping<i16>, Wrapping<i32>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<i32>, Wrapping<i64>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<i64>, Wrapping<i128>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<i8>, Wrapping<i16>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<u16>, Wrapping<u32>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<u32>, Wrapping<u64>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<u64>, Wrapping<u128>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<Wrapping<u8>, Wrapping<u16>, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<i16, i32, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<i32, i64, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<i64, i128, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<i8, i16, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<u16, u32, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<u32, u64, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<u64, u128, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<const F: i8> ConstOne for Q<u8, u16, F>

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<T: ConstZero, A, const F: i8> ConstZero for Q<T, A, F>

Source§

const ZERO: Self

The additive identity element of Self, 0.
Source§

impl<T: Debug, A, const F: i8> Debug for Q<T, A, F>

Source§

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

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

impl<T: Default, A: Default, const F: i8> Default for Q<T, A, F>

Source§

fn default() -> Q<T, A, F>

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

impl<'de, T, A, const F: i8> Deserialize<'de> for Q<T, A, F>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, A, const F: i8> Display for Q<T, A, F>
where Self: Copy + AsPrimitive<f64>,

Source§

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

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

impl<const F: i8> Div<Q<Wrapping<i16>, Wrapping<i32>, F>> for Wrapping<i16>

T/Q -> T

Source§

type Output = Wrapping<i16>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<i16>, Wrapping<i32>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<i32>, Wrapping<i64>, F>> for Wrapping<i32>

T/Q -> T

Source§

type Output = Wrapping<i32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<i32>, Wrapping<i64>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<i64>, Wrapping<i128>, F>> for Wrapping<i64>

T/Q -> T

Source§

type Output = Wrapping<i64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<i64>, Wrapping<i128>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<i8>, Wrapping<i16>, F>> for Wrapping<i8>

T/Q -> T

Source§

type Output = Wrapping<i8>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<i8>, Wrapping<i16>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<u16>, Wrapping<u32>, F>> for Wrapping<u16>

T/Q -> T

Source§

type Output = Wrapping<u16>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<u16>, Wrapping<u32>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<u32>, Wrapping<u64>, F>> for Wrapping<u32>

T/Q -> T

Source§

type Output = Wrapping<u32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<u32>, Wrapping<u64>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<u64>, Wrapping<u128>, F>> for Wrapping<u64>

T/Q -> T

Source§

type Output = Wrapping<u64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<u64>, Wrapping<u128>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<Wrapping<u8>, Wrapping<u16>, F>> for Wrapping<u8>

T/Q -> T

Source§

type Output = Wrapping<u8>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<Wrapping<u8>, Wrapping<u16>, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<i16, i32, F>> for i16

T/Q -> T

Source§

type Output = i16

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<i16, i32, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<i32, i64, F>> for i32

T/Q -> T

Source§

type Output = i32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<i32, i64, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<i64, i128, F>> for i64

T/Q -> T

Source§

type Output = i64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<i64, i128, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<i8, i16, F>> for i8

T/Q -> T

Source§

type Output = i8

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<i8, i16, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<u16, u32, F>> for u16

T/Q -> T

Source§

type Output = u16

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<u16, u32, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<u32, u64, F>> for u32

T/Q -> T

Source§

type Output = u32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<u32, u64, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<u64, u128, F>> for u64

T/Q -> T

Source§

type Output = u64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<u64, u128, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<const F: i8> Div<Q<u8, u16, F>> for u8

T/Q -> T

Source§

type Output = u8

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Q<u8, u16, F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Div<Output = T>, A, const F: i8> Div<T> for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self

Performs the / operation. Read more
Source§

impl<T, A, const F: i8> Div for Q<T, A, F>
where Self: DivAssign,

Q/Q -> Q

assert_eq!(Q8::<4>::from_int(3) / Q8::from_int(2), Q8::from_f32(1.5));
Source§

type Output = Q<T, A, F>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Copy + Shift + Accu<A> + Div<T, Output = T>, A: Shift + Div<A, Output = A>, const F: i8, const F1: i8> DivAssign<Q<T, A, F1>> for Q<T, A, F>

Q /= Q’

let mut q = Q8::<4>::from_f32(0.75);
q /= Q8::<3>::from_int(3);
assert_eq!(q, Q8::from_f32(0.25));
Source§

fn div_assign(&mut self, rhs: Q<T, A, F1>)

Performs the /= operation. Read more
Source§

impl<T: DivAssign<T>, A, const F: i8> DivAssign<T> for Q<T, A, F>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Accu<A> + Shift, A, const F: i8> From<(T, i8)> for Q<T, A, F>

Lossy conversion from a dynamically scaled integer

assert_eq!(Q8::<8>::from((1, 3)).inner, 1 << 5);
Source§

fn from(value: (T, i8)) -> Self

Converts to this type from the input type.
Source§

impl<T, A, const F: i8> From<Q<T, A, F>> for (T, i8)

Lossless conversion into a dynamically scaled integer

let q: (i8, i8) = Q8::<8>::new(9).into();
assert_eq!(q, (9, 8));
Source§

fn from(value: Q<T, A, F>) -> Self

Converts to this type from the input type.
Source§

impl<T, A, const F: i8> LowerExp for Q<T, A, F>
where Self: Copy + AsPrimitive<f64>,

Source§

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

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

impl<T: LowerHex, A, const F: i8> LowerHex for Q<T, A, F>

Source§

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

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

impl<const F: i8> Mul<Q<Wrapping<i16>, Wrapping<i32>, F>> for Wrapping<i16>

T*Q -> T

Source§

type Output = Wrapping<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<i16>, Wrapping<i32>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<i32>, Wrapping<i64>, F>> for Wrapping<i32>

T*Q -> T

Source§

type Output = Wrapping<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<i32>, Wrapping<i64>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<i64>, Wrapping<i128>, F>> for Wrapping<i64>

T*Q -> T

Source§

type Output = Wrapping<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<i64>, Wrapping<i128>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<i8>, Wrapping<i16>, F>> for Wrapping<i8>

T*Q -> T

Source§

type Output = Wrapping<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<i8>, Wrapping<i16>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<u16>, Wrapping<u32>, F>> for Wrapping<u16>

T*Q -> T

Source§

type Output = Wrapping<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<u16>, Wrapping<u32>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<u32>, Wrapping<u64>, F>> for Wrapping<u32>

T*Q -> T

Source§

type Output = Wrapping<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<u32>, Wrapping<u64>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<u64>, Wrapping<u128>, F>> for Wrapping<u64>

T*Q -> T

Source§

type Output = Wrapping<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<u64>, Wrapping<u128>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<Wrapping<u8>, Wrapping<u16>, F>> for Wrapping<u8>

T*Q -> T

Source§

type Output = Wrapping<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<Wrapping<u8>, Wrapping<u16>, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<i16, i32, F>> for i16

T*Q -> T

Source§

type Output = i16

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<i16, i32, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<i32, i64, F>> for i32

T*Q -> T

Source§

type Output = i32

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<i32, i64, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<i64, i128, F>> for i64

T*Q -> T

Source§

type Output = i64

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<i64, i128, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<i8, i16, F>> for i8

T*Q -> T

Source§

type Output = i8

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<i8, i16, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<u16, u32, F>> for u16

T*Q -> T

Source§

type Output = u16

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<u16, u32, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<u32, u64, F>> for u32

T*Q -> T

Source§

type Output = u32

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<u32, u64, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<u64, u128, F>> for u64

T*Q -> T

Source§

type Output = u64

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<u64, u128, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const F: i8> Mul<Q<u8, u16, F>> for u8

T*Q -> T

Source§

type Output = u8

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Q<u8, u16, F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Accu<A>, A: Mul<Output = A>, const F: i8> Mul<T> for Q<T, A, F>

Wide multiplication to accumulator

assert_eq!(Q8::<3>::new(4) * 2, Q::new(8));
assert_eq!(Q8::<3>::new(4) / 2, Q8::new(2));
Source§

type Output = Q<A, T, F>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Q<A, T, F>

Performs the * operation. Read more
Source§

impl<T, A, const F: i8> Mul for Q<T, A, F>
where Self: MulAssign,

Q*Q -> Q

assert_eq!(
    Q8::<4>::from_f32(0.75) * Q8::from_int(3),
    Q8::from_f32(2.25)
);
Source§

type Output = Q<T, A, F>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Copy + Accu<A>, A: Shift + Mul<A, Output = A>, const F: i8, const F1: i8> MulAssign<Q<T, A, F1>> for Q<T, A, F>

Q *= Q’

let mut q = Q8::<4>::from_f32(0.25);
q *= Q8::<3>::from_int(3);
assert_eq!(q, Q8::from_f32(0.75));
Source§

fn mul_assign(&mut self, rhs: Q<T, A, F1>)

Performs the *= operation. Read more
Source§

impl<T: MulAssign<T>, A, const F: i8> MulAssign<T> for Q<T, A, F>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Neg<Output = T>, A, const F: i8> Neg for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: Not<Output = T>, A, const F: i8> Not for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<T: Octal, A, const F: i8> Octal for Q<T, A, F>

Source§

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

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

impl<T: One + Shift, A, const F: i8> One for Q<T, A, F>
where Self: Mul<Output = Self>,

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T: Ord, A, const F: i8> Ord for Q<T, A, F>
where Self: PartialOrd,

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<T: PartialEq, A, const F: i8> PartialEq for Q<T, A, F>

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<T: PartialOrd, A, const F: i8> PartialOrd for Q<T, A, F>

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<T: Rem<T, Output = T>, A, const F: i8> Rem for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<T: RemAssign<T>, A, const F: i8> RemAssign for Q<T, A, F>

Source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
Source§

impl<T, A, const F: i8> Serialize for Q<T, A, F>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<U, T: Shl<U, Output = T>, A, const F: i8> Shl<U> for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: U) -> Self::Output

Performs the << operation. Read more
Source§

impl<T: ShlAssign<U>, U, A, const F: i8> ShlAssign<U> for Q<T, A, F>

Source§

fn shl_assign(&mut self, rhs: U)

Performs the <<= operation. Read more
Source§

impl<U, T: Shr<U, Output = T>, A, const F: i8> Shr<U> for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: U) -> Self::Output

Performs the >> operation. Read more
Source§

impl<T: ShrAssign<U>, U, A, const F: i8> ShrAssign<U> for Q<T, A, F>

Source§

fn shr_assign(&mut self, rhs: U)

Performs the >>= operation. Read more
Source§

impl<T: Sub<T, Output = T>, A, const F: i8> Sub for Q<T, A, F>

Source§

type Output = Q<T, A, F>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: SubAssign<T>, A, const F: i8> SubAssign for Q<T, A, F>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T: Sum, A, const F: i8> Sum for Q<T, A, F>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T, A, const F: i8> UpperExp for Q<T, A, F>
where Self: Copy + AsPrimitive<f64>,

Source§

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

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

impl<T: UpperHex, A, const F: i8> UpperHex for Q<T, A, F>

Source§

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

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

impl<T: Zero, A, const F: i8> Zero for Q<T, A, F>
where Self: Add<Output = Self>,

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T: Copy, A, const F: i8> Copy for Q<T, A, F>

Source§

impl<T: Eq, A, const F: i8> Eq for Q<T, A, F>
where Self: PartialEq,

Auto Trait Implementations§

§

impl<T, A, const F: i8> Freeze for Q<T, A, F>
where T: Freeze,

§

impl<T, A, const F: i8> RefUnwindSafe for Q<T, A, F>

§

impl<T, A, const F: i8> Send for Q<T, A, F>
where T: Send, A: Send,

§

impl<T, A, const F: i8> Sync for Q<T, A, F>
where T: Sync, A: Sync,

§

impl<T, A, const F: i8> Unpin for Q<T, A, F>
where T: Unpin, A: Unpin,

§

impl<T, A, const F: i8> UnwindSafe for Q<T, A, F>
where T: UnwindSafe, A: 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> Shift for T
where T: Shl<usize, Output = T> + Shr<usize, Output = T> + Copy,

Source§

fn shs(self, f: i8) -> T

Signed shift (positive: left) Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,