Fixing bug in multiplication implementation

This commit is contained in:
Tomasz Drwięga 2016-03-09 11:32:23 +01:00
parent c47209e9bf
commit b3fc16ed9a

View File

@ -407,7 +407,7 @@ macro_rules! uint_overflowing_mul_reg {
let (b_u, b_l) = split(you[i]); let (b_u, b_l) = split(you[i]);
for j in 0..$n_words { for j in 0..$n_words {
if me[j] == 0 { if me[j] == 0 && carry2 == 0 {
continue; continue;
} }
@ -1640,6 +1640,14 @@ mod tests {
assert_eq!(U256::from(1u64) * U256::from(10u64), U256::from(10u64)); assert_eq!(U256::from(1u64) * U256::from(10u64), U256::from(10u64));
} }
#[test]
pub fn uint256_mul2() {
let a = U512::from_str("10000000000000000fffffffffffffffe").unwrap();
let b = U512::from_str("ffffffffffffffffffffffffffffffff").unwrap();
assert_eq!(a * b, U512::from_str("10000000000000000fffffffffffffffcffffffffffffffff0000000000000002").unwrap());
}
#[test] #[test]
pub fn uint256_overflowing_mul() { pub fn uint256_overflowing_mul() {
assert_eq!( assert_eq!(