| 1966 | // grade-school multiplication algorithm |
| 1967 | template <uint16_t size> |
| 1968 | bool long_mul(stackvec<size>& x, limb_span y) noexcept { |
| 1969 | limb_span xs = limb_span(x.data, x.len()); |
| 1970 | stackvec<size> z(xs); |
| 1971 | limb_span zs = limb_span(z.data, z.len()); |
| 1972 | |
| 1973 | if (y.len() != 0) { |
| 1974 | limb y0 = y[0]; |
| 1975 | FASTFLOAT_TRY(small_mul(x, y0)); |
| 1976 | for (size_t index = 1; index < y.len(); index++) { |
| 1977 | limb yi = y[index]; |
| 1978 | stackvec<size> zi; |
| 1979 | if (yi != 0) { |
| 1980 | // re-use the same buffer throughout |
| 1981 | zi.set_len(0); |
| 1982 | FASTFLOAT_TRY(zi.try_extend(zs)); |
| 1983 | FASTFLOAT_TRY(small_mul(zi, yi)); |
| 1984 | limb_span zis = limb_span(zi.data, zi.len()); |
| 1985 | FASTFLOAT_TRY(large_add_from(x, zis, index)); |
| 1986 | } |
| 1987 | } |
| 1988 | } |
| 1989 | |
| 1990 | x.normalize(); |
| 1991 | return true; |
| 1992 | } |
| 1993 | |
| 1994 | // grade-school multiplication algorithm |
| 1995 | template <uint16_t size> |
no test coverage detected