BigInt.toTwosComplement
private
void toTwosComplement(const(ulong)[] mag, bool negative,
size_t w, ulong[] ext) static pure @safeConverts a magnitude limb array into w-limb two's-complement form.
The magnitude is zero-extended to w limbs; for negative values the zero-extended magnitude is inverted and one is added, which yields all-ones sign-extension limbs. (Padding with ulong.max before inverting would turn the sign-extension limbs into zeros and corrupt the value.)
Parameters
mag | Magnitude limbs (little-endian). |
negative | Whether the value is negative. |
w | Window width in limbs; must be >= mag.length, and must include one extra limb when negative is set so the converted pattern never aliases a positive value. |
ext | Output buffer of w limbs. |