use crate::big_digit::{BigDigit, DoubleBigDigit, BITS};
#[inline]
pub fn adc(a: BigDigit, b: BigDigit, acc: &mut DoubleBigDigit) -> BigDigit {
    *acc += a as DoubleBigDigit;
    *acc += b as DoubleBigDigit;
    let lo = *acc as BigDigit;
    *acc >>= BITS;
    lo
}
#[inline]
pub fn __add2(a: &mut [BigDigit], b: &[BigDigit]) -> BigDigit {
    debug_assert!(a.len() >= b.len());
    let mut carry = 0;
    let (a_lo, a_hi) = a.split_at_mut(b.len());
    for (a, b) in a_lo.iter_mut().zip(b) {
        *a = adc(*a, *b, &mut carry);
    }
    if carry != 0 {
        for a in a_hi {
            *a = adc(*a, 0, &mut carry);
            if carry == 0 {
                break;
            }
        }
    }
    carry as BigDigit
}
pub fn add2(a: &mut [BigDigit], b: &[BigDigit]) {
    let carry = __add2(a, b);
    debug_assert!(carry == 0);
}