From 46d89619bd746ddf0dc225ad668a15f7ac4d9904 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 29 Aug 2024 20:03:56 -0700 Subject: [PATCH] use from_bits function for consts --- fixed_wide/src/fixed.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 23a8774..b26a4ed 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -9,17 +9,17 @@ pub struct Fixed{ } impl Fixed{ - pub const MAX:Self=Self{bits:BInt::::MAX,frac:PhantomData}; - pub const MIN:Self=Self{bits:BInt::::MIN,frac:PhantomData}; - pub const ZERO:Self=Self{bits:BInt::::ZERO,frac:PhantomData}; - pub const EPSILON:Self=Self{bits:BInt::::ONE,frac:PhantomData}; - pub const NEG_EPSILON:Self=Self{bits:BInt::::NEG_ONE,frac:PhantomData}; - pub const ONE:Self=Self{bits:BInt::::ONE.shl(Frac::U32),frac:PhantomData}; - pub const TWO:Self=Self{bits:BInt::::TWO.shl(Frac::U32),frac:PhantomData}; - pub const HALF:Self=Self{bits:BInt::::ONE.shl(Frac::U32-1),frac:PhantomData}; - pub const NEG_ONE:Self=Self{bits:BInt::::NEG_ONE.shl(Frac::U32),frac:PhantomData}; - pub const NEG_TWO:Self=Self{bits:BInt::::NEG_TWO.shl(Frac::U32),frac:PhantomData}; - pub const NEG_HALF:Self=Self{bits:BInt::::NEG_ONE.shl(Frac::U32-1),frac:PhantomData}; + pub const MAX:Self=Self::from_bits(BInt::::MAX); + pub const MIN:Self=Self::from_bits(BInt::::MIN); + pub const ZERO:Self=Self::from_bits(BInt::::ZERO); + pub const EPSILON:Self=Self::from_bits(BInt::::ONE); + pub const NEG_EPSILON:Self=Self::from_bits(BInt::::NEG_ONE); + pub const ONE:Self=Self::from_bits(BInt::::ONE.shl(Frac::U32)); + pub const TWO:Self=Self::from_bits(BInt::::TWO.shl(Frac::U32)); + pub const HALF:Self=Self::from_bits(BInt::::ONE.shl(Frac::U32-1)); + pub const NEG_ONE:Self=Self::from_bits(BInt::::NEG_ONE.shl(Frac::U32)); + pub const NEG_TWO:Self=Self::from_bits(BInt::::NEG_TWO.shl(Frac::U32)); + pub const NEG_HALF:Self=Self::from_bits(BInt::::NEG_ONE.shl(Frac::U32-1)); pub const fn from_bits(bits:BInt::)->Self{ Self{ bits,