| 2112 | // used in grade school multiplication |
| 2113 | template <uint16_t size> |
| 2114 | FASTFLOAT_CONSTEXPR20 |
| 2115 | bool large_add_from(stackvec<size>& x, limb_span y, size_t start) noexcept { |
| 2116 | // the effective x buffer is from `xstart..x.len()`, so exit early |
| 2117 | // if we can't get that current range. |
| 2118 | if (x.len() < start || y.len() > x.len() - start) { |
| 2119 | FASTFLOAT_TRY(x.try_resize(y.len() + start, 0)); |
| 2120 | } |
| 2121 | |
| 2122 | bool carry = false; |
| 2123 | for (size_t index = 0; index < y.len(); index++) { |
| 2124 | limb xi = x[index + start]; |
| 2125 | limb yi = y[index]; |
| 2126 | bool c1 = false; |
| 2127 | bool c2 = false; |
| 2128 | xi = scalar_add(xi, yi, c1); |
| 2129 | if (carry) { |
| 2130 | xi = scalar_add(xi, 1, c2); |
| 2131 | } |
| 2132 | x[index + start] = xi; |
| 2133 | carry = c1 | c2; |
| 2134 | } |
| 2135 | |
| 2136 | // handle overflow |
| 2137 | if (carry) { |
| 2138 | FASTFLOAT_TRY(small_add_from(x, 1, y.len() + start)); |
| 2139 | } |
| 2140 | return true; |
| 2141 | } |
| 2142 | |
| 2143 | // add bigint to bigint. |
| 2144 | template <uint16_t size> |
no test coverage detected