From edb309f50c989925549952e2699bee5e1f8f2daa Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Fri, 7 Sep 2018 10:38:51 -0600 Subject: [PATCH] Use u128 addition rather than u64 overflowing addition --- src/fq.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fq.rs b/src/fq.rs index 4223b36..8f724a6 100644 --- a/src/fq.rs +++ b/src/fq.rs @@ -75,8 +75,8 @@ fn adc2(a: u64, b: u64, carry: u64) -> (u64, u64) { /// Compute a + b, returning the result and the carry over. #[inline(always)] fn overflowing_add(a: u64, b: u64) -> (u64, u64) { - let (sum, overflow) = a.overflowing_add(b); - (sum, overflow as u64) + let sum = u128::from(a) + u128::from(b); + (sum as u64, (sum >> 64) as u64) } /// Compute a - (b + borrow), returning the result and setting borrow to