5 // Add with carry, returning the sum and the carry
6 fn overflowing_add(a: u64, b: u64, carry: bool) -> (u64, bool) {
7 let sum = u64::wrapping_add(a, b);
9 panic!("First addition did not overflow. Not implemented.");
11 panic!("First addition *did* overflow. Not implemented.");
16 fn test_overflowing_add() {
17 assert_eq!(overflowing_add(10, 100, false), (110, false));
18 assert_eq!(overflowing_add(10, 100, true), (111, false));
19 assert_eq!(overflowing_add(1 << 63, 1 << 63, false), (0, true));
20 assert_eq!(overflowing_add(1 << 63, 1 << 63, true), (1, true));
21 assert_eq!(overflowing_add(1 << 63, (1 << 63) -1 , true), (0, true));
24 impl ops::Add for BigInt {
26 fn add(self, rhs: BigInt) -> Self::Output {
27 let mut result_vec:Vec<u64> = Vec::with_capacity(cmp::max(self.data.len(), rhs.data.len()));
28 panic!("Not yet implemented.");