So, you have a smart phone, maybe a laptop or a desktop, but have you ever wondered how exactly computers work in a detailed yet simple fashion?
Well, we all know that computers manipulate binary digits (called bits) in the form of electronic voltages to compute everything. From weather forecast to blog posts, cat videos to integration everything. But how exactly? Pardon me if it has some mathematics, but it will be extremely simple, comprehensible and if you try a bit, easy.
DISCLAIMER: I have tried my best to keep mistakes out-of-the-way. But there might be some mistakes that goes unforeseen. So, if you find any mistakes, do leave a comment, I am quick to fix my mistakes and give you editing/proofreading credits. And if you find it difficult, try to understand and re-read, informative things aren’t as easy as porn, they do take some efforts to understand.
Very basics of computers: Binary
So, you all have read and re-read about binary but do you have a clear idea about binary? (if you do, please skip this part) Let’s start with counting. Well binary has 2 digits, 0 and 1. Just forget about existence of digits 2-9.
In decimal you start at 0,1,2,3,4,5,6,7,8,9 and no more digits. What do you do? You take 1 and add 0 behind and continue. This is the decimal place system. 10 actually refers to the concept of 9+1. But we use the symbol 10 to denote it. This way, we can not run out of numbers.
But what if, we use 0,1 and then apply the rule, it will continue like 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010. This may not look familiar, but it is simpler. The value of 102 It’s 2 (I wrote the 2 to tell it’s a binary and not decimal).
Remember, computers do not have anything like 1 or 0, they know Ground voltage state (off) and high voltage state (on). So, 1 and 0 are our representations. For computers, everything is an electric voltage. And they differences and patterns make everything possible.
Converting to and from binary
This is also a topic I don’t necessarily need to cover but I will still do it. So, you don’t need to leave this page.
Let’s start by converting decimal into decimal. Doesn’t make sense? Here’s what it is
25 = 2×10 + 5
623 = 6×100 + 2×10 + 5
Oh well, now you remember its called place value. Every digit has it’s place value, multiplied by the value to denote the number. But we can think of it like this (in case you don’t recall, any number raised to the power of zero is 1)
25 = 2×10 + 5×1
= 2×101 + 5×100
623 = 6x10x10 + 2×10 + 5×1
= 6×102 + 2×101 + 3×100
Now see, the pattern, we take the number, multiply by the base (here 10 for 10 total symbols) and we go up a power of 10 as we go from right to left (count starts at 0). Let’s apply it to binary
10102 = 1×23 + 0x22 + 1×21 + 0x20
= 1×8+1×2 = 8+2 = 10
1012 = 1×22 + 0x21 + 1×20
= 1×4+1×1 = 4+1 = 5
And this is how you can change from decimal to binary, divide the number by two and note the remainder.
Divide the quotient by two and note the remainder.
Keep doing it until you reach 0.
Now, note all the remainders Backwards.
Poof! You have your binary representation
If you need more details, there will be links in the bottom of this page where I will link relevant and useful posts. Here I will update an interactive demo for you to see how the binary and decimal data relates.
Okay I understand Binary numbers, but what about 10.5? Negative numbers?
We call decimal numbers as “floating point numbers” in binary and we have a way to represent them. But not so fast, we are going ahead of ourselves. I will link to the article where I will describe floating point numbers in intricate detail. For now, you can scroll to the bottom of this page and read about floating point numbers in more detail. If you really need it now.
Likewise, We represent negative numbers (called signed integers) using something called an two’s complement representation. basically, we use bits for storing numbers, floating point numbers, negative numbers and everything. And they’re called data representation.
Well, what about alphabets? How do computers represent them?
Well, although I told you I am not going to show you data representations. But I think “alphabets” are interesting and simple enough that you can have a look.
Without digging too much, there are several ways computers can represent text data. (by the way, each individual component of a text data is called a “character” and not “alphabet” because even “1” is a character when displaying as a text, “,” is a character as well)
Back in the days, everyone used their own tables for characters, One company says wfq21 is A, another company would say 41 is A. That means everything you write on one computer would be corrupted on another. This couldn’t work. Some guys set up a committee, (too bad nobody setup a whatsapp group) and agreed on a set of code. Here A was 65. And every computer displayed that ever since. So, now, your text files are same, everywhere.
The name of the code was ASCII (American Standard Code of Information Interchange) and Yes! even Russia uses it. I sometimes wonder how rude it was for them for naming a standard after America. Which is acceptable everywhere. I would say we should name it to ISCII or USCII (international or universal, but universal is impolite, that would mean even aliens have to use it and they might not even have the same characters!)
In the next Part, there will be ton of exciting new things. Computers require some understanding of binary logic so, I had to dedicate the first part to Binary.
Data Representations Nanya
Down here, I would add another interactive demo before moving on to next part.
ng University of technology, Singapore: https://www3.ntu.edu.sg/home/ehchua/programming/java/datarepresentation.html
Ryan’s tutorials: Floating Point: https://ryanstutorials.net/binary-tutorial/binary-floating-point.php
ASCII Table: http://www.asciitable.com/
Pages: 1 2