8-bit Data Representation Visualizer • Created by Sam Li
Overflow Occurred!
The value exceeded the 8-bit signed range (-128 to 127) and wrapped around.
Two's complement is the standard way computers represent signed (positive and negative) integers. It is brilliant because it allows addition and subtraction to be performed by the exact same hardware logic circuit. It also eliminates the confusing problem of having two representations for zero (+0 and -0) which existed in older systems.
In an 8-bit signed integer, the leftmost bit (Most Significant Bit) acts as the sign bit. If it's 0, the number is positive. If it's 1, the number is negative. The remaining 7 bits help determine the magnitude.
An 8-bit signed integer can only store a specific range of values: from -128 to 127. If a calculation (like adding 1 to 127) results in a number outside this physical memory limit, an overflow occurs. The value "wraps around" to the other end of the spectrum (127 + 1 becomes -128). This happens because the binary carry bit spills over into the sign bit, unexpectedly changing the number's sign.
1. Start with the positive binary number.
2. Invert all bits (0 becomes 1, 1 becomes 0).
3. Add 1 to the result.
Try it: Type 5 in the input box, click "Invert Bits", then click "+ 1". You will get -5!