Have you ever wondered how computers understand numbers? Unlike humans who use the familiar decimal system (base 10), computers use the binary number system, which is based on only two digits: 0 and 1. This system is called base-2 because it uses two symbols to represent all numbers.
The binary system is fundamental in digital electronics and computing because electronic circuits have two states: ON and OFF, which naturally correspond to 1 and 0. Understanding binary is essential not only for computer science but also for competitive exams, especially those testing quantitative aptitude and number systems.
In this chapter, we will explore how binary numbers work, how to convert between binary and decimal systems, perform arithmetic operations in binary, and understand their applications. By the end, you will be confident in handling binary numbers and related problems.
Just like the decimal system uses digits 0 to 9 and place values based on powers of 10, the binary system uses only two digits, called bits (short for binary digits): 0 and 1.
Each bit in a binary number has a place value that is a power of 2, starting from the rightmost bit (called the least significant bit). The place values increase as you move left.
| Bit Position (from right) | Place Value (2n) | Example Binary Digit | Decimal Equivalent |
|---|---|---|---|
| 0 | 20 = 1 | 1 | 1 x 1 = 1 |
| 1 | 21 = 2 | 0 | 0 x 2 = 0 |
| 2 | 22 = 4 | 1 | 1 x 4 = 4 |
| 3 | 23 = 8 | 1 | 1 x 8 = 8 |
For example, the binary number 1101 can be read as:
Adding these gives 8 + 4 + 0 + 1 = 13 in decimal.
Why is place value important? Because it tells us how much each digit contributes to the overall number, depending on its position.
To work comfortably with binary numbers, you need to know how to convert between binary and decimal systems.
graph TD A[Start] --> B[To convert Binary to Decimal] B --> C[Write down the binary number] C --> D[Multiply each bit by 2^position] D --> E[Sum all the results] E --> F[Decimal equivalent obtained] A --> G[To convert Decimal to Binary] G --> H[Divide decimal number by 2] H --> I[Write down remainder (0 or 1)] I --> J[Divide quotient by 2 again] J --> K[Repeat until quotient is 0] K --> L[Read remainders in reverse order] L --> M[Binary equivalent obtained]
101101 into its decimal equivalent. Step 1: Write down the place values for each bit (from right to left):
Positions: 5 4 3 2 1 0
Bits: 1 0 1 1 0 1
Place values: \( 2^5 = 32, 2^4 = 16, 2^3 = 8, 2^2 = 4, 2^1 = 2, 2^0 = 1 \)
Step 2: Multiply each bit by its place value:
Step 3: Add all the results:
32 + 0 + 8 + 4 + 0 + 1 = 45
Answer: The decimal equivalent of binary 101101 is 45.
Step 1: Divide 45 by 2:
45 / 2 = 22 remainder 1
Step 2: Divide 22 by 2:
22 / 2 = 11 remainder 0
Step 3: Divide 11 by 2:
11 / 2 = 5 remainder 1
Step 4: Divide 5 by 2:
5 / 2 = 2 remainder 1
Step 5: Divide 2 by 2:
2 / 2 = 1 remainder 0
Step 6: Divide 1 by 2:
1 / 2 = 0 remainder 1
Step 7: Write the remainders from bottom to top:
1 0 1 1 0 1
Answer: The binary equivalent of decimal 45 is 101101.
Just like decimal numbers, binary numbers can be added, subtracted, multiplied, and divided. However, the rules differ slightly because binary digits are only 0 or 1.
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| Minuend | Subtrahend | Difference | Borrow |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 (borrow) |
Note: Borrowing in binary means borrowing a value of 2 (since base is 2), unlike decimal where you borrow 10.
1101 and 1011. Write the numbers aligned by place value:
1 1 0 1 + 1 0 1 1 ---------
Step 1: Add rightmost bits: 1 + 1 = 0 carry 1
Step 2: Next bits: 0 + 1 + carry 1 = 0 carry 1
Step 3: Next bits: 1 + 0 + carry 1 = 0 carry 1
Step 4: Leftmost bits: 1 + 1 + carry 1 = 1 carry 1
Step 5: Write down the carry 1 at the leftmost position.
Carry: 1 1 1 1 1 1 0 1 + 1 0 1 1 ----------- Result:1 1 0 0 0
Answer: The sum is 11000.
1001 from 10110. Align the numbers by place value (pad with leading zeros if needed):
1 0 1 1 0 - 0 1 0 0 1 -----------
Step 1: Subtract rightmost bits: 0 - 1. Cannot subtract, borrow 1 from next bit.
Borrowing means next bit reduces by 1, and current bit adds 2.
Now, 2 - 1 = 1.
Step 2: Next bit: originally 1, after borrowing becomes 0.
Subtract 0 - 0 = 0.
Step 3: Next bit: 1 - 0 = 1.
Step 4: Next bit: 0 - 1. Cannot subtract, borrow from leftmost bit.
Leftmost bit reduces from 1 to 0, current bit becomes 2.
2 - 1 = 1.
Step 5: Leftmost bit: 0 - 0 = 0.
Result: 0 1 1 0 1
Answer: The result of 10110 - 1001 is 1101.
So far, we have dealt with positive binary numbers. But how do computers represent negative numbers? The answer lies in the two's complement system.
Two's complement allows us to represent negative numbers in binary and perform arithmetic operations seamlessly.
How to find the two's complement of a binary number?
01011. Step 1: Invert all bits:
Original: 0 1 0 1 1
Inverted: 1 0 1 0 0
Step 2: Add 1 to the inverted number:
10100 + 1 = 10101
Answer: The two's complement of 01011 is 10101.
When to use: When converting binary to decimal.
When to use: When converting decimal to binary.
When to use: When performing binary addition.
When to use: When representing negative numbers in binary.
When to use: When converting between binary and octal/hexadecimal.
Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.
Go to practice →