diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 9ed0f1a..7abb1fc 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -155,24 +155,23 @@ impl_shift_operator!( Fixed, Shr, shr, Self ); impl Fixed{ pub fn sqrt_unchecked(self)->Self{ - let mut pow2=if self==Self::ZERO{ - return Self::ZERO; - }else if self>=1; } pow2 - }else if self==Self::ONE{ - return Self::ONE; - }else{ - //find pow2 more powerful than self - let mut pow2=Self::ONE; - while pow2<=self{ - pow2<<=1; - } - pow2 + }else{//either 0==self or self is negative + return Self::ZERO; }; let mut result=pow2; while pow2!=Self::ZERO{