From e46f4fb9001c79297e764f9c015454b208111d3f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 25 Sep 2024 10:07:41 -0700 Subject: [PATCH] save a copy in sqrt using epic bnum 0.12 feature (pulled by yours truly) --- fixed_wide/src/fixed.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 446d957..a8bf944 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -708,7 +708,11 @@ macro_rules! impl_not_const_generic{ let wide_self=self.[](); //descend down the bits and check if flipping each bit would push the square over the input value for shift in (0..=max_shift).rev(){ - let new_result=result|Self::from_bits(BInt::from_bits(bnum::BUint::power_of_two(shift))); + let new_result={ + let mut bits=result.to_bits().to_bits(); + bits.set_bit(shift,true); + Self::from_bits(BInt::from_bits(bits)) + }; if new_result.[](new_result)<=wide_self{ result=new_result; }