Converters: Unsigned and One’s Complement (Negative)

A) Non-negative ↔ Unsigned Binary

Accepts only 0/1 in binary and integers ≥ 0. Uses BigInt so large numbers are OK.

B) Negative ↔ One’s-Complement Binary (fixed width)

One’s complement: represent +x in binary, then flip bits to get −x. Range for N bits is from -(2^(N-1)-1) to +(2^(N-1)-1). There are two zeros: 000...0 (+0) and 111...1 (−0).