BigInt.toTwosComplement

private void toTwosComplement(const(ulong)[] mag, bool negative, size_t w, ulong[] ext) static pure @safe

Converts 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

magMagnitude limbs (little-endian).
negativeWhether the value is negative.
wWindow 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.
extOutput buffer of w limbs.