Why not?
Have Have you ever wondered how do the computers work?
How How do they store numbers?
What What causes "floating point precision problems"?
Why does my hard drive shows 931GB instead of 1000GB, assuming it's a 1TB hard drive.
Why can't I use more than 4GB of RAM in 32bit Windows?
After learning binary, you'll be able to answer them easily.
So, let's get going!
0 1
0 1 2 3 4 5 6 7 8 9
You probably already know this even if you're new to computer science that computers use 0's and 1's. Computers use transistors as switches and a switch has two states, ON and OFF, ON creating a 1 and OFF creating a 0. So, basically computers speak the same language that we do but they only have 0's and 1's at their disposal.
Fun fact! There are literally billions of transistors inside your laptop, smartphone etc. You can learn more about transistors here.
You're probably now wondering that how do they work with only two numbers?
Consider this, We humans use the Decimal system that has 10 digits or Base 10, mentioned above. We represent numbers with their number places, One's, Ten's, Hundreds... and so on.
To represent 131 in decimal, We write131 which works as 100 + 30 + 1
1 | 3 | 1 |
---|---|---|
100 | 10 | 1 |
102 | 101 | 100 |
In Binary, we have only two digits 0 and 1 or Base 2 to represent numbers. So, the place values will be One's, Two's, Four's... and so on. It's the same concept as Decimal.
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
So by this logic, I encourage you to think about how can you represent something simple like 2 in binary.
After giving it a shot, you can click below to change the value to 2.
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
It's now probably fairly intuitive to you how binary works.
Every column can hold either 1 or 0. So, to write 2, we need two columns because the first column's maximum value is 1 because it's the one's place. The second column has the maximum value of 2 because it's the two's place. So, we put a 1 in the two's column and 0 in the one's column, now the value is 2.
Below, there are 5 diagrams or whatever you want to call them, large font numbers?
Anyways, the first represents 3 in binary, then the next 4 and the last 7. After giving it a shot, click on the respective diagram to reveal the answer.
This represents 3
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
This represents 4
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
This represents 5
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
This represents 6
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
This represents 7
0 | 0 | 0 |
---|---|---|
4 | 2 | 1 |
22 | 21 | 20 |
You probably now understand that how binary works and how simple it is.
Now, I need you to think about that how you might display 8 in binary. After giving it a shot, you can click on the next paragraph to decrypt it.
Vg'f fvzcyr, lbh jvyy whfg nqq nabgure pbyhza nsgre sbhe'f cynpr naq gung pbyhza jvyy unir gur cynpr inyhr bs rvtug'f.
1 | 0 | 0 | 0 |
---|---|---|---|
8 | 4 | 2 | 1 |
23 | 22 | 21 | 20 |
You're Done! You now know how to display numbers in binary. There's a practice session below to make you even more comfortable with binary. Check it out after reading this section.
Every column or place value is called a Bit and 8 bits are called a Byte.
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 Bit | 1 Bit | 1 Bit | 1 Bit | 1 Bit | 1 Bit | 1 Bit | 1 Bit |
The Next Thing! You're probably are now wondering that how does the computer displays alphabets and more?
Many years ago, In the computer world, people adopted a method that maps numbers to letters. This is called ASCII(American Standard Code for Information Interchange) and it is just a table that maps numbers to alphabets.
Below there's an ASCII table of some commonly used characters. You can check all of them here.
You can click on the header (ASCII) to hide/unhide the table.
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Uppercase A
Uppercase B
Uppercase C
Uppercase D
Uppercase E
Uppercase F
Uppercase G
Uppercase H
Uppercase I
Uppercase J
Uppercase K
Uppercase L
Uppercase M
Uppercase N
Uppercase O
Uppercase P
Uppercase Q
Uppercase R
Uppercase S
Uppercase T
Uppercase U
Uppercase V
Uppercase W
Uppercase X
Uppercase Y
So, I previously told you that 8bits are called a Byte. There's a bit more to that, 1024Bytes are called a Kilobyte(KB) and 1024KB are called a Megabyte(MB) and 1024MB are called a Gigabyte(GB) and 1024GB are called a Terabyte(TB) and so on. You can check out all of them here.
Now, I encourage you to think about the answer to the question proposed above "Why does my hard drive shows 931GB instead of 1000GB, assuming it's a 1TB hard drive.". Hint - Companies advertise hard drives as 1TB which means 1000GB but a computer doesn't work that way. After giving it a shot, you can click below to decrypt the answer.
Gur uneq qevir unf 1000TO nf nqiregvfrq ohg pbzchgre pnyhyngrf vg va gur cbjre bs 2 . Fb, 1000TO pbairegrq vagb Olgrf vf 1r+12(1 gura 12 mrebf nsgre gung) naq ol qvivqvat vg ol gur ynetrfg cbjre bs 2 gung pna svg va 1000TO juvpu vf 1024 3 be 2 30 juvpu erfhyg va gur nafjre 931TO.
Now you can understand this joke! In December 2014, Google made a joke that Gangnam Style by Psy broke the Youtube's counter because they didn't think that any video will ever cross the maximum possible views which are the max value of 32bit integer which is 2,147,483,647. The had already seen this coming and changed it to 64bit integer which has a max value of 9,223,372,036,854,775,807!
Here's a gif of the easter egg
This is the same thing that happens with the question "Why can't I use more than 4GB of RAM or even 4GB in 32bit windows" but just a little different. It's gonna be a little complicated if you don't know anything about memory in computers.
So, here we go, When you open up a program that program gets loaded into memory(RAM) and a memory address is assigned to it. You can convert 4GB of memory in bytes to see how many address it can hold which turns out to be 4 * 230and every address is 4Bytes long, it depends on the operating system. A memory address is the location of where the program is stored and memory addresses are also just made up of bytes. So, the first limit is that the number of addresses is limited to the amount of memory you have stored.
Now, assuming the CPU is 32 bit, there is nothing as 32bit, 64bit CPU nowadays, they are just an instruction set. The CPU now needs to access those memory address that has the program to do the calculations. Now comes the second limit, a 32bit CPU/OS(Operating System) can only assign a max of
232- 1(because the addresses start from 0) different addresses and this is called machine word.
Now, addresses and the bytes are the same 4 * 230 = 232. Now, you might be thinking that computer can now store 4GB of RAM right?. Yeah, theoretically but in the real world, there are other components who needs some RAM like the graphic card. So, after assigning everybody the RAM that they require, a computer only sees the RAM that is left which in turn is less than 4GB.
There are ways to overcome this known as Physical Address Extension. You can check it out here.
There's also a thing known as Virtual memory which you can check out here.
00011001 00001111 00010101 00000000 00000001 00010010 00000101 00000000 00000001 00010111 00000101 00010011 00001111 00001101 00000101
Practice App
0
0
0
0
0
0
0
0
128
64
32
16
8
4
2
1
Current Streak: 0
Enter in binary
Highest Streak: 0