| 2150 | // grade-school multiplication algorithm |
| 2151 | template <uint16_t size> |
| 2152 | FASTFLOAT_CONSTEXPR20 |
| 2153 | bool long_mul(stackvec<size>& x, limb_span y) noexcept { |
| 2154 | limb_span xs = limb_span(x.data, x.len()); |
| 2155 | stackvec<size> z(xs); |
| 2156 | limb_span zs = limb_span(z.data, z.len()); |
| 2157 | |
| 2158 | if (y.len() != 0) { |
| 2159 | limb y0 = y[0]; |
| 2160 | FASTFLOAT_TRY(small_mul(x, y0)); |
| 2161 | for (size_t index = 1; index < y.len(); index++) { |
| 2162 | limb yi = y[index]; |
| 2163 | stackvec<size> zi; |
| 2164 | if (yi != 0) { |
| 2165 | // re-use the same buffer throughout |
| 2166 | zi.set_len(0); |
| 2167 | FASTFLOAT_TRY(zi.try_extend(zs)); |
| 2168 | FASTFLOAT_TRY(small_mul(zi, yi)); |
| 2169 | limb_span zis = limb_span(zi.data, zi.len()); |
| 2170 | FASTFLOAT_TRY(large_add_from(x, zis, index)); |
| 2171 | } |
| 2172 | } |
| 2173 | } |
| 2174 | |
| 2175 | x.normalize(); |
| 2176 | return true; |
| 2177 | } |
| 2178 | |
| 2179 | // grade-school multiplication algorithm |
| 2180 | template <uint16_t size> |
no test coverage detected