TwosComplementRegister implements a twos complement register of arbitrary width. It consists of an array of bits (boolean values) and methods to perform bit arithmetic. A register accumulates the results of successive operations, and maintains an overflow bit to indicate status of the preceding operation.
The current state of a register may represent either an unsigned integer or a signed integer. In either case, the many register operations (addition, subtraction, multiplication) are identical. When interpreted as a signed integer, the high order bit of the register is treated as the sign bit, and the integer value is determined by the remaining bits.
A register may be of any width, although powers of two (8, 16, 32 ...) will match the expectations of data types in conventional programming languages.
All operations are implemented in terms of boolean logic without reliance on numbers.