Binary 101: The Language of Computers
by Zvonimir Tomesic, CEO
Series: From Binary to Processors: A Deep Dive into Digital Logic
-
Binary 101: The Language Of Computers
-
Number Systems: Binary, Decimal, Octal, Hexadecimal (coming soon)
-
Boolean Algebra: The Foundation Of Digital Logic (coming soon)
-
Logic Gates: The Building Blocks Of Digital Logic (coming soon)
-
Error Correction In Digital Systems: Understanding Hamming Code And Beyond (coming soon)
-
Digital Arithmetic Circuits: From Basic Adders To Complex Chips (coming soon)
-
The Anatomy Of Processors: ALU, Clock, And Core Components (coming soon)
In the beginning
Imagine a time when the most groundbreaking invention was the wheel. This simple, circular object set the stage for the agricultural revolution, transforming societies from nomadic tribes to settled communities. As centuries rolled on, human ingenuity didn't stop there. The steam engine roared to life, heralding the industrial revolution and reshaping cities and economies. Then, the world was electrified, quite literally, as the discovery of electricity illuminated our homes and powered our industries.
Yet, as transformative as these inventions were, none could have predicted the revolution that a tiny piece of silicon would bring. Enter the era of transistors, the building blocks of modern electronics. These minuscule components, no larger than a grain of sand, paved the way for the digital age we live in today.
But before we dive deep into the complexities of modern computing, let's start with a concept as fundamental as the wheel was to transportation: binary.
Binary as a language
Every language has an alphabet, a set of symbols or characters used to construct words and sentences. In most languages, these symbols are letters. However, in binary, the entire alphabet consists of just two symbols: 1 and 0.
Binary is a base-2 number system, in contrast to the decimal system which is base-10. This means that while we count using numbers 0 through 9 in decimal, in binary, we only use 0 and 1.
When we want a computer to recognize a letter, we represent that letter in its binary form. For instance:
A => 01000001, a => 01100001
B => 01000010, b => 01100010
C => 01000011, c => 01100011
Similarly, numbers can also be represented in binary:
1 => 00000001
2 => 00000010
3 => 00000011
To visualize how computers interpret numbers, consider the number 13:
Binary | Value | Decimal |
---|---|---|
1 | 1 | 1 |
0 | 2 | 0 |
1 | 4 | 4 |
1 | 8 | 8 |
0 | 16 | 0 |
0 | 32 | 0 |
0 | 64 | 0 |
0 | 128 | 0 |
Total | 13 |
Mathematically, this can be represented as:
00001101
=> 0*2^7
+ 0*2^6
+ 0*2^5
+ 0*2^4
+ 1*2^3
+ 1*2^2
+ 0*2^1
+ 1*2^0
= 13
Binary Aritmetics
With a foundational understanding of binary, we can delve into binary arithmetic operations.
Addition
Binary addition is quite straightforward, but it's essential to understand a few basic rules to handle the process correctly.
Basic Rules for Binary Addition:
- 0 + 0 = 0
- 1 + 0 = 1
- 0 + 1 = 1
- 1 + 1 = 0 (with a carry of 1)
For example, when adding 26 and 12:
26 => 00011010
12 => 00001100
38 => 00100110
Here's a step-by-step breakdown:
- Add the rightmost bits of 26 (0) and 12 (0). The result is 0.
- Move to the next column. Add 1 (from 26) and 0 (from 12). The result is 1.
- Continue this process for each column.
- When you reach the third column from the right, adding 1 (from 26) and 1 (from 12) results in 0 with a carry of 1 to the next column.
- The final result is 00100110, which is 38 in decimal.
First binary number | Second binary number | Sum | Carry |
---|---|---|---|
0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
0 | 1 | 1 | 0 |
1 | 1 | 0 | 1 |
1 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
Subtraction
In binary, subtraction is akin to addition. Computers perform subtraction using addition:
C = A – B
C = A + (-B)
For instance, for 30 - 15:
C = 30 - 15
A => 30 = 00011110
B => 15 = 00001111
(-B) => 11110000 + 1 = 11110001
C => 00011110 + 11110001 = 00001111
First binary number | Second binary number | Sum | Carry |
---|---|---|---|
0 | 1 | 1 | 0 |
1 | 0 | 1 | 0 |
1 | 0 | 1 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 1 |
0 | 1 | 0 | 1 |
0 | 1 | 0 | 1 |
0 | 1 | 0 | 1 |
Multiplication
Binary multiplication is straightforward and mirrors the multiplication process in the decimal system. However, since we only have two digits in binary (0 and 1), the multiplication rules are much simpler.
Basic Rules for Binary Multiplication:
- 0 x 0 = 0
- 0 x 1 = 0
- 1 x 0 = 0
- 1 x 1 = 1
To better understand multiplication, let’s look at the example.
26 => 00011010
12 => 00001100
26 * 12 = 312
00011010 * 00001100 = 100111000
00011010 (This is 26)
x 00001100 (This is 12)
____________
00000000 (26 multiplied by 0)
00011010 (26 multiplied by 0, shifted one position to the left)
00011010 (26 multiplied by 1, shifted two positions to the left)
00000000 (26 multiplied by 0, shifted three positions to the left)
____________
100111000 (Sum of all the products, which is 312 in decimal)
Here's a step-by-step breakdown:
- Multiply 26 (00011010) by the rightmost bit of 12 (0). The product is 00000000.
- Multiply 26 by the next bit of 12 (0) and shift the result one position to the left.
- Multiply 26 by the next bit of 12 (1) and shift the result two positions to the left. This gives 00011010.
- Multiply 26 by the leftmost bit of 12 (0) and shift the result three positions to the left.
- Sum all the individual products to get the final result: 100111000, which is 312 in decimal.
Operation | Binary | Decimal | Decimal Multi. |
---|---|---|---|
Multiplicand | 11010 | 26 | 26 |
Multiplier | 01100 | 12 | 12 |
Partial product | 00000 | 12 | |
Partial product | 000000 | 0 | 40 |
Partial product | 1101000 | 104 | 60 |
Partial product | 11010000 | 208 | 200 |
Final product | 100111000 | 312 | 312 |
Division
Binary division is similar to the long division method we learned in school, but with only two digits: 0 and 1. The process involves repeatedly subtracting the divisor from the dividend and keeping track of the quotient and remainder.
Basic Rules for Binary Subtraction:
0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
0 - 1
requires borrowing. Just like in decimal subtraction where you'd borrow from the next column, in binary, you borrow a1
making the current column10
. Thus,10 - 1 = 1
.
Example: Dividing 39 by 3 in Binary
dividend 39 => 00100111
divisor 3 => 00000011
Quotient
00001101
___________
00000011 | 00100111
- 11
_________
011
- 11
_________
0011
- 11
_________
0 (Remainder)
Here's a step-by-step breakdown:
- Subtract the divisor 11 from the first part of the dividend 1001. The result is 011.
- Bring down the next bit from the dividend, making it 0110.
- Subtract the divisor 11 again. The result is 0011.
- Bring down the final bit from the dividend, making it 0011.
- Subtract the divisor 11 one last time. The result is 0, which is our remainder.
- The quotient from this division is 00001101 or 13 in decimal.
Operation | Binary | Binary | Decimal |
---|---|---|---|
Quotient | 00001101 | 13 | |
Divisor / Dividend | 00000011 | 00100111 | 3 / 39 |
- | 00011 | 3 | |
Subtraction result | 000011 | 3 | |
- | 000011 | 3 | |
Rest | 00000000 | 0 |
In the end
In our upcoming series, we'll delve deeper into the details of digital logic, exploring the gates that shape our digital decisions and the algorithms that drive our online experiences. We'll demystify the magic behind the screens (no pun intended), from the vast world of data structures to the real-time operations that keep our world ticking.
So, stay tuned. The digital age is vast, and our exploration has only just begun. Join us as we continue to unravel the marvels of the computing universe, one article at a time.