From 20a317612ed8c80eb315bcfd3579bcfc2f13e99d Mon Sep 17 00:00:00 2001 From: Quaternions <krakow20@gmail.com> Date: Tue, 27 Aug 2024 16:49:49 -0700 Subject: [PATCH] fixed: constants --- fixed_wide/src/fixed.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 5f72a47..ab18621 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -8,6 +8,12 @@ pub struct Fixed<const CHUNKS:usize,Frac>{ pub(crate)frac:PhantomData<Frac>, } +impl<const CHUNKS:usize,Frac:Unsigned> Fixed<CHUNKS,Frac>{ + pub const ZERO:Self=Self{bits:BInt::<CHUNKS>::ZERO,frac:PhantomData}; + pub const ONE:Self=Self{bits:BInt::<CHUNKS>::ONE.shl(Frac::U32),frac:PhantomData}; + pub const NEG_ONE:Self=Self{bits:BInt::<CHUNKS>::NEG_ONE.shl(Frac::U32),frac:PhantomData}; +} + impl<const CHUNKS:usize,FracDst:Unsigned,T> From<T> for Fixed<CHUNKS,FracDst> where BInt<CHUNKS>:From<T>