mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
math.big: add_digit_array() refactoring
This commit is contained in:
parent
b99c3826ce
commit
dbb5692907
1 changed files with 6 additions and 5 deletions
|
@ -34,11 +34,15 @@ fn add_digit_array(operand_a []u64, operand_b []u64, mut sum []u64) {
|
|||
for index in 0 .. operand_b.len {
|
||||
sum[index] = operand_b[index]
|
||||
}
|
||||
shrink_tail_zeros(mut sum)
|
||||
return
|
||||
}
|
||||
if operand_b.len == 0 {
|
||||
for index in 0 .. operand_a.len {
|
||||
sum[index] = operand_a[index]
|
||||
}
|
||||
shrink_tail_zeros(mut sum)
|
||||
return
|
||||
}
|
||||
|
||||
// First pass intersects with both operands
|
||||
|
@ -62,11 +66,8 @@ fn add_digit_array(operand_a []u64, operand_b []u64, mut sum []u64) {
|
|||
carry = u64(partial >> digit_bits)
|
||||
}
|
||||
|
||||
if carry == 0 {
|
||||
sum.delete_last()
|
||||
} else {
|
||||
sum[larger_limit] = carry
|
||||
}
|
||||
sum[larger_limit] = carry
|
||||
shrink_tail_zeros(mut sum)
|
||||
}
|
||||
|
||||
// Subtracts operand_b from operand_a and stores the difference in storage.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue