From 49e077996d84b8cc306b49a3904f94eb5550979e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 2 Dec 2023 01:24:52 -0800 Subject: [PATCH] overflow detect --- src/zeroes.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/zeroes.rs b/src/zeroes.rs index d75581fa..0991dd07 100644 --- a/src/zeroes.rs +++ b/src/zeroes.rs @@ -28,7 +28,12 @@ pub fn zeroes2(a0:Planar64,a1:Planar64,a2:Planar64) -> Vec{ pub fn zeroes1(a0:Planar64,a1:Planar64) -> Vec { if a1==Planar64::ZERO{ return vec![]; - } else { - return vec![-a0/a1]; + }else{ + let q=((-a0.get() as i128)<<32)/(a1.get() as i128); + if i64::MIN as i128<=q&&q<=i64::MAX as i128{ + return vec![Planar64::raw(q as i64)]; + }else{ + return vec![]; + } } } \ No newline at end of file