Two's complement represents signed integers in a fixed-width binary register. The leading bit distinguishes nonnegative values from negative values: an m-bit string covers −2^(m−1) through 2^(m−1)−1. section 10.1.5
In quantum function encoding, two's complement provides a practical interpretation for value qubits:
- Strings beginning with 0 represent nonnegative outputs. section 10.1.5
- Strings beginning with 1 represent negative outputs. section 10.1.5
- With four value qubits, the representable range is −8 through 7. section 11.1
- A grid-state visualization can display negative values by setting neg=True. section 10.1.5
Encoding f(k) = k² − 3
For inputs 0 through 3, the lowest output is −3 and the highest is 0. The output −3 is encoded as 1101 in a four-bit value register; the function's grid shape remains the same but shifts to include negative values. section 10.1.5
Figure 10.10 The quantum state encoding the function f(k) = k2 – 3 for 0 ≤ k < 4
View the quantum-state figure for f(k) = k² − 3 and its two's complement output encoding. section 10.1.5



