ignore overflow in point norm computation
authoralfadur
Thu, 29 Aug 2019 21:25:23 +0300
changeset 15384 1c6d5656157c
parent 15383 701ad89a9f2a
child 15385 c35c5a9b878c
ignore overflow in point norm computation
rust/integral-geometry/src/lib.rs
--- a/rust/integral-geometry/src/lib.rs	Thu Aug 29 00:20:41 2019 +0300
+++ b/rust/integral-geometry/src/lib.rs	Thu Aug 29 21:25:23 2019 +0300
@@ -45,7 +45,7 @@
 
     #[inline]
     pub fn integral_norm(self) -> u32 {
-        let sqr = (self.x as u64).pow(2) + (self.y as u64).pow(2);
+        let sqr = (self.x as u64).wrapping_pow(2) + (self.y as u64).wrapping_pow(2);
         integral_sqrt(sqr) as u32
     }