| 3697 | // used in grade school multiplication |
| 3698 | template <uint16_t size> |
| 3699 | FASTFLOAT_CONSTEXPR20 bool large_add_from(stackvec<size> &x, limb_span y, |
| 3700 | size_t start) noexcept { |
| 3701 | // the effective x buffer is from `xstart..x.len()`, so exit early |
| 3702 | // if we can't get that current range. |
| 3703 | if (x.len() < start || y.len() > x.len() - start) { |
| 3704 | FASTFLOAT_TRY(x.try_resize(y.len() + start, 0)); |
| 3705 | } |
| 3706 | |
| 3707 | bool carry = false; |
| 3708 | for (size_t index = 0; index < y.len(); index++) { |
| 3709 | limb xi = x[index + start]; |
| 3710 | limb yi = y[index]; |
| 3711 | bool c1 = false; |
| 3712 | bool c2 = false; |
| 3713 | xi = scalar_add(xi, yi, c1); |
| 3714 | if (carry) { |
| 3715 | xi = scalar_add(xi, 1, c2); |
| 3716 | } |
| 3717 | x[index + start] = xi; |
| 3718 | carry = c1 | c2; |
| 3719 | } |
| 3720 | |
| 3721 | // handle overflow |
| 3722 | if (carry) { |
| 3723 | FASTFLOAT_TRY(small_add_from(x, 1, y.len() + start)); |
| 3724 | } |
| 3725 | return true; |
| 3726 | } |
| 3727 | |
| 3728 | // add bigint to bigint. |
| 3729 | template <uint16_t size> |
no test coverage detected