MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / large_add_from

Function large_add_from

app/src/ThirdParty/fast_float.h:3699–3726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3697// used in grade school multiplication
3698template <uint16_t size>
3699FASTFLOAT_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.
3729template <uint16_t size>

Callers 1

long_mulFunction · 0.85

Calls 4

scalar_addFunction · 0.85
small_add_fromFunction · 0.85
try_resizeMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected