From 6cb639317c43fd538f0a712ed24e1274276864e3 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 11 Sep 2024 15:15:06 -0700 Subject: [PATCH] const helpers --- fixed_wide/src/fixed.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 91d4eae..da334f5 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -40,6 +40,22 @@ impl Fixed{ digits[N-1]|=(value&i64::MIN) as u64; Self::from_bits(BInt::from_bits(bnum::BUint::from_digits(digits))) } + #[inline] + pub const fn is_zero(self)->bool{ + self.bits.is_zero() + } + #[inline] + pub const fn is_negative(self)->bool{ + self.bits.is_negative() + } + #[inline] + pub const fn is_positive(self)->bool{ + self.bits.is_positive() + } + #[inline] + pub const fn abs(self)->Self{ + Self::from_bits(self.bits.abs()) + } } impl Fixed<1,F>{ /// My old code called this function everywhere so let's provide it