diff --git a/src/integer.rs b/src/integer.rs index 377a097..c034fd9 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -453,7 +453,23 @@ impl Planar64{ } #[inline] pub fn sqrt(&self)->Self{ - Planar64(unsafe{(((self.0 as i128)<<32) as f64).sqrt().to_int_unchecked()}) + const BITS:i32=64; + const FRAC:i32=32; + let mut pow2=Self::raw(1i64<<(((BITS-FRAC-(self.0.leading_zeros() as i32)+1)>>1)+FRAC).saturating_sub(1)); + let mut result=pow2; + let wide_self=(self.0 as i128)<(), + core::cmp::Ordering::Equal=>break new_result, + core::cmp::Ordering::Greater=>result=new_result, + } + pow2=Self::raw(pow2.0>>1); + } } #[inline] pub const fn signum_i64(&self)->i64{