Binary arithmetic: add, subtract, multiply and divide
Build two byte values from their bits, then watch the machine work through addition, subtraction, multiplication or division one step at a time.
Number basics
In one binary place, 1 + 1 makes 0 and carries 1 to the next place. The subscript 2 means “this number is binary.”
What the column sum means
For one column, add the A bit, the B bit and the carry from the previous column. This small sum can be 0, 1, 2 or 3. Write its rightmost binary digit. Carry its left digit to the next column.
0 + 0 + 0 = 0 = 0₂Write: 0 Carry: 00 + 1 + 0 = 1 = 1₂Write: 1 Carry: 01 + 1 + 0 = 2 = 10₂Write: right digit 0 Carry: left digit 11 + 1 + 1 = 3 = 11₂Write: right digit 1 Carry: left digit 18-bit arithmetic machine
Click bit buttons to set A and B. Each operand stays between 0 and 255. Choose an operation, then step through how the bits change.
Choose A and B
Operand A
Decimal · hex
Binary
Operand B
Decimal · hex
Binary
Addition, one bit per step
Result bits light as they are written
This machine treats A and B as unsigned bytes. Addition and subtraction keep an 8-bit result and show carry or borrow. Multiplication shows the full 16-bit product. Division gives an integer quotient and remainder. Z80 arithmetic instructions also affect flags; this visual machine focuses on the bit operations.