Courses / Computer Science I
Introduction to Computers

Arithmetic at Machine Level

Computer Science I 177 words Free to read

Doing Sums in Binary

Computers add binary numbers using carry rules where 1+1=101+1=10 (which is 00 carry 11). Adding 011+001011 + 001 yields 100100: the rightmost 1+11+1 makes 00 carry 11, the middle column becomes 00 carry 11, and the final column takes the carry.

Because a register holds a fixed width, any sum requiring extra bits suffers from overflow: the high bit is lost. In an 8-bit register, 255+1255 + 1 wraps to 00. This hardware behavior is entirely silent; software must account for it explicitly.

Signed Numbers and Two's Complement

Negative values use two's complement, where you invert all bits and add 1. The leftmost bit is the sign bit (00 for positive, 11 for negative). This lets the standard adder handle subtraction natively.

8-bit patternValue
0000000100000001+1+1
11111111111111111-1
1000000010000000128-128
0111111101111111+127+127
Pitfall: Assuming integers grow infinitely. Machine limits mean signed +127+1+127 + 1 wraps silently to 128-128. Always watch your fixed widths!
Negation as a real procedure -- invert every bit, then add one

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

10practice questions
2interactive scenes

Introduction to Computers