From 2240b80656df4661d770434f024b85d5373af147 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 14 Oct 2023 15:42:16 -0700 Subject: [PATCH] sqrt + test --- src/integer.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/integer.rs b/src/integer.rs index bd43b639..3d052ecd 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -421,6 +421,9 @@ impl Planar64{ pub const fn get(&self)->i64{ self.0 } + pub fn sqrt(&self)->Self{ + Planar64(unsafe{(((self.0 as i128)<<32) as f64).sqrt().to_int_unchecked()}) + } } const PLANAR64_FLOAT32_ONE:f32=(1u64<<32) as f32; const PLANAR64_FLOAT32_MUL:f32=1.0/PLANAR64_FLOAT32_ONE; @@ -911,4 +914,12 @@ impl std::fmt::Display for Planar64Affine3{ Into::::into(self.matrix3.z_axis.x()),Into::::into(self.matrix3.z_axis.y()),Into::::into(self.matrix3.z_axis.z()), ) } +} + +#[test] +fn test_sqrt(){ + let r=Planar64::int(400); + println!("r{}",r.get()); + let s=r.sqrt(); + println!("s{}",s.get()); } \ No newline at end of file