Skip to main content

Q

Struct Q 

Source
pub struct Q<T, A, const F: i8> { /* 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::from_bits(3 << 4));
assert_eq!(7 * Q8::<4>::from_f32(1.5), 10);
assert_eq!(Q8::<4>::from_f32(1.5).apply(7), 10);
assert_eq!(7 / Q8::<4>::from_f32(1.5), 4);

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));
let _ = Q32::<-128>::DELTA;
Source

pub const fn from_bits(bits: T) -> Self

Create a new fixed point number from a raw representation.

Source

pub fn into_bits(self) -> T

Return the raw representation.

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>::from_bits(32).scale::<0>(), Q8::from_bits(2));
Source

pub fn trunc(self) -> T

Return the integer part

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

pub fn from_int(value: T) -> Self

Scale from integer base type

assert_eq!(Q8::<4>::from_int(7).into_bits(), 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: Accu<A>, A: Mul<Output = A>, const F: i8> Q<T, A, F>

Source

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

Multiply by a raw integer and keep the widened accumulator result.

assert_eq!(Q8::<3>::from_bits(4).mul_wide(2), Q::from_bits(8));
Source§

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

Source

pub fn apply(self, rhs: T) -> T

Apply this fixed-point value as a gain to a raw integer and quantize.

assert_eq!(Q8::<4>::from_f32(0.25).apply(7), 1);
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: AsFloat, A, const F: i8> Q<T, A, F>

Source

pub fn as_f32(self) -> f32

Convert lossy to f32

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 f32
where f32: AsPrimitive<T>, T: 'static + Copy, A: 'static,

Source§

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

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

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

Source§

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

Convert a value to another, using the as operator.
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<const F: i8> AsPrimitive<Wrapping<i8>> for Q<Wrapping<i16>, Wrapping<i8>, F>

Source§

fn as_(self) -> Wrapping<i8>

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>

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

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

Source§

fn as_(self) -> Wrapping<i32>

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

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

Source§

fn as_(self) -> Wrapping<i64>

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

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

Source§

fn as_(self) -> Wrapping<u8>

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

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

Source§

fn as_(self) -> Wrapping<u16>

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

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

Source§

fn as_(self) -> Wrapping<u32>

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

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

Source§

fn as_(self) -> Wrapping<u64>

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

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

Source§

fn as_(self) -> f32

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

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

Source§

fn as_(self) -> f64

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

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

Source§

fn as_(self) -> i8

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

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

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

Source§

fn as_(self) -> i32

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

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

Source§

fn as_(self) -> i64

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

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

Source§

fn as_(self) -> u8

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

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

Source§

fn as_(self) -> u16

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

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

Source§

fn as_(self) -> u32

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

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

Source§

fn as_(self) -> u64

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

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

Source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Self

Returns the largest finite number this type can represent
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 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
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<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<u8, u16, 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<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<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<u8>, Wrapping<u16>, 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<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: Copy, A, const F: i8> Copy for Q<T, A, F>

Source§

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

Binary, octal, and hexadecimal formatting always include the fixed-point radix point. Even whole-valued cases keep a trailing . to distinguish them from raw integer formatting.

assert_eq!(format!("{:?}", Q8::<4>::from_bits(0x14)), "20");
assert_eq!(format!("{:#b}", Q8::<3>::from_bits(0b01101001)), "0b1101.001");
assert_eq!(format!("{:x}", Q8::<-2>::from_bits(3)), "c.");
assert_eq!(format!("{:x}", Q8::<4>::from_bits(-0x14)), "-1.4");
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 T: AsFloat,

Source§

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

Formats the value using the given formatter. 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<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<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<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<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<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<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<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<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<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: 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: Eq, A, const F: i8> Eq for Q<T, A, F>
where Self: PartialEq,

Source§

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

Available on crate feature defmt only.
Source§

fn format(&self, fmt: Formatter<'_>)

Writes the defmt representation of self to fmt.
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)).into_bits(), 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>::from_bits(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> FromPrimitive for Q<T, A, F>
where T: 'static + Copy + FromPrimitive + Shift, A: 'static, f32: AsPrimitive<Q<T, A, F>>, f64: AsPrimitive<Q<T, A, F>>, Self: Copy + 'static,

Source§

fn from_i64(n: i64) -> Option<Self>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_u64(n: u64) -> Option<Self>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

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

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

Source§

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

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

impl<T: RadixValue, 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<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<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<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<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<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<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<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<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<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<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>::from_bits(4) * 2, Q::from_bits(8));
assert_eq!(Q8::<3>::from_bits(4) / 2, Q8::from_bits(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: 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, A, const F: i8> Num for Q<T, A, F>
where T: Num + Shift + Accu<A> + Copy + Div<T, Output = T>, A: Shift + Copy + Div<A, Output = A>, Self: One + Zero,

Source§

type FromStrRadixErr = <T as Num>::FromStrRadixErr

Source§

fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl<T: RadixValue, 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<const F: i8> One for Q<i8, i16, F>

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

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<const F: i8> One for Q<i32, i64, F>

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<const F: i8> One for Q<i64, i128, F>

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<const F: i8> One for Q<u8, u16, F>

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<const F: i8> One for Q<u16, u32, F>

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<const F: i8> One for Q<u32, u64, F>

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<const F: i8> One for Q<u64, u128, F>

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

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

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

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<const F: i8> One for Q<Wrapping<i64>, Wrapping<i128>, F>

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<const F: i8> One for Q<Wrapping<u8>, Wrapping<u16>, F>

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<const F: i8> One for Q<Wrapping<u16>, Wrapping<u32>, F>

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<const F: i8> One for Q<Wrapping<u32>, Wrapping<u64>, F>

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<const F: i8> One for Q<Wrapping<u64>, Wrapping<u128>, F>

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 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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, A, const F: i8> Pod for Q<T, A, F>
where T: Pod, A: Pod,

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<A, const F: i8> Signed for Q<i8, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<Wrapping<i8>, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<i16, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<Wrapping<i16>, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<i32, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<Wrapping<i32>, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<i64, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl<A, const F: i8> Signed for Q<Wrapping<i64>, A, F>
where Self: Num + Neg<Output = Self>,

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
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: Shift + ToPrimitive + AsFloat, A, const F: i8> ToPrimitive for Q<T, A, F>

Source§

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
Source§

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
Source§

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
Source§

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
Source§

fn to_f32(&self) -> Option<f32>

Converts the value of self to an f32. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f32.
Source§

fn to_f64(&self) -> Option<f64>

Converts the value of self to an f64. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f64. Read more
Source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
Source§

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
Source§

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
Source§

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
Source§

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
Source§

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
Source§

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
Source§

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
Source§

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

Source§

fn wrap(s: Inner) -> Self
where Self: Sized, Inner: Sized,

Convert the inner type into the wrapper type.
Source§

fn wrap_ref(s: &Inner) -> &Self

Convert a reference to the inner type into a reference to the wrapper type.
Source§

fn wrap_mut(s: &mut Inner) -> &mut Self

Convert a mutable reference to the inner type into a mutable reference to the wrapper type.
Source§

fn wrap_slice(s: &[Inner]) -> &[Self]
where Self: Sized, Inner: Sized,

Convert a slice to the inner type into a slice to the wrapper type.
Source§

fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]
where Self: Sized, Inner: Sized,

Convert a mutable slice to the inner type into a mutable slice to the wrapper type.
Source§

fn peel(s: Self) -> Inner
where Self: Sized, Inner: Sized,

Convert the wrapper type into the inner type.
Source§

fn peel_ref(s: &Self) -> &Inner

Convert a reference to the wrapper type into a reference to the inner type.
Source§

fn peel_mut(s: &mut Self) -> &mut Inner

Convert a mutable reference to the wrapper type into a mutable reference to the inner type.
Source§

fn peel_slice(s: &[Self]) -> &[Inner]
where Self: Sized, Inner: Sized,

Convert a slice to the wrapped type into a slice to the inner type.
Source§

fn peel_slice_mut(s: &mut [Self]) -> &mut [Inner]
where Self: Sized, Inner: Sized,

Convert a mutable slice to the wrapped type into a mutable slice to the inner type.
Source§

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

Source§

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

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

impl<T: RadixValue, 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, A, const F: i8> Zeroable for Q<T, A, F>
where T: Zeroable, A: Zeroable,

Source§

fn zeroed() -> Self

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> UnsafeUnpin for Q<T, A, F>
where T: UnsafeUnpin,

§

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> AnyBitPattern for T
where T: Pod,

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> LowerBounded for T
where T: Bounded,

Source§

fn min_value() -> T

Returns the smallest finite number this type can represent
Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> NumAssign for T
where T: Num + NumAssignOps,

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>,

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§

fn shsc<const F: i8>(self) -> Self

Const signed shift
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> UpperBounded for T
where T: Bounded,

Source§

fn max_value() -> T

Returns the largest finite number this type can represent