static T add(T z, T x, T y) { int n = y->ndigits; if (x->ndigits < n) return add(z, y, x); else if (x->ndigits > n) { int carry = XP_add(n, z->digits, x->digits, y->digits, 0); z->digits[z->size-1] = XP_sum(x->ndigits - n, &z->digits[n], &x->digits[n], carry); } else z->digits[n] = XP_add(n, z->digits, x->digits, y->digits, 0); return normalize(z, z->size); }
T MP_addu(T z, T x, T y) { int carry; assert(x); assert(y); assert(z); carry = XP_add(nbytes, z, x, y, 0); carry |= z[nbytes-1]&~msb; z[nbytes-1] &= msb; if (carry) RAISE(MP_Overflow); return z; }
T MP_add(T z, T x, T y) { int sx, sy; assert(x); assert(y); assert(z); sx = sign(x); sy = sign(y); XP_add(nbytes, z, x, y, 0); z[nbytes-1] &= msb; if (sx == sy && sy != sign(z)) RAISE(MP_Overflow); return z; }