CS With NehalCS With Nehal

Number System Operations

Add, subtract and multiply two or more numbers in binary, octal, denary or hexadecimal, with carries, borrows, overflow and underflow shown.

Numbers & operation

= 11 in denary
+= 6 in denary
+= 13 in denary

Working

Line the numbers up by place value and start at the rightmost column. In base 2 a column carries 2.

Step 1 / 6
Carry
1011
+0110
+1101
Result
30
Answer (denary)
11110
Answer (binary)
11110
Binary
1E
Hex
The result fits in a 8-bit register.
Check: convert each number to denary, do the sum there, then convert back. Both answers must match.

About This Simulation

This number system operations simulator does arithmetic directly in binary, octal, denary or hexadecimal. Addition and subtraction run one column at a time with carries and borrows explained, binary subtraction can also be done with two's complement, and multiplication is shown as partial products.

Features

  • Add or subtract up to six numbers in base 2, 8, 10 or 16
  • Carry and borrow row above the columns, with the final carry shown in the result
  • Binary subtraction using two's complement (A + (−B))
  • Long multiplication with partial products
  • Register size option with overflow and underflow warnings

Topics covered

  • Binary Arithmetic
  • Hexadecimal and Octal Arithmetic
  • Carry and Borrow
  • Two's Complement Subtraction
  • Binary Multiplication

Explanation

Arithmetic works the same way in any base: you work from the rightmost column, and a column carries when its total reaches the base. In binary a column carries at 2, in octal at 8 and in hexadecimal at 16. Subtraction borrows one of the base from the next column when the top digit is too small.

How it works

  1. Addition: add the digits in a column plus any carry. If the total is at least the base, write total − base and carry 1.
  2. Subtraction: if the top digit (minus any borrow) is smaller than the bottom digit, borrow the base from the next column.
  3. Two's complement subtraction: find −B by inverting B and adding 1, then add it to A. A carry out of the leftmost bit is ignored.
  4. Multiplication: multiply A by each digit of B, shift each partial product one place left per position, then add them. In binary each partial product is 0 or A shifted.
  5. Check any answer by converting to denary, calculating there and converting back.

Why it matters

Binary addition and subtraction are on the IGCSE syllabus, and hexadecimal arithmetic is useful for memory addresses and colour codes. In digital logic courses (CSE230, CSE260) the same ideas lead to adder and subtractor circuits.

Frequently Asked Questions

How do you add in hexadecimal?

Add each column in denary. If the total is 16 or more, subtract 16, write that digit (using A–F for 10–15) and carry 1. For example 9 + 8 = 17 → write 1, carry 1.

How does a computer subtract binary numbers?

It adds the two's complement of the second number: A − B = A + (NOT B + 1). This means the same adder circuit performs subtraction.

What does borrowing mean in binary subtraction?

When subtracting 1 from 0, take 1 from the next column, which is worth 2 in the current column, so 10₂ − 1 = 1.

Related Simulations