Fixing bug in multiplication implementation
This commit is contained in:
parent
c47209e9bf
commit
b3fc16ed9a
@ -407,7 +407,7 @@ macro_rules! uint_overflowing_mul_reg {
|
||||
let (b_u, b_l) = split(you[i]);
|
||||
|
||||
for j in 0..$n_words {
|
||||
if me[j] == 0 {
|
||||
if me[j] == 0 && carry2 == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1640,6 +1640,14 @@ mod tests {
|
||||
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]
|
||||
pub fn uint256_overflowing_mul() {
|
||||
assert_eq!(
|
||||
|
Loading…
Reference in New Issue
Block a user