1.1) Introduction: Data representation on computer
1.1.1) What is meant by data representation on computer hardware?
By data representation inside the computer, we mean how to speak to the computer in its language … To explain more
In the course overview, we said that the goal of computer science is to study algorithms, and we said that an algorithm is just a finite number of steps you should follow to solve a certain problem.
Imagine with me: what if you have a problem and you want to ask your friend to help? Suppose your friend speaks a different language; say Arabic. How to tell your friend about the problem you have and its algorithm in Arabic First, you need to think about what you want to say in English and then convert that to Arabic. What you did was represent your English words in Arabic.
The same is true on the computer. To make the computer execute a certain algorithm, you need to represent that algorithm in the computer language. Here we need to ask 2 questions:
The first question is: what is the language of the computer? You will say 0s and 1s, of course. That is right. We call it a binary language because it consists only of 2 symbols, 0 and 1. Therefore, data representation inside the computer means how to convert the data in our language to a binary language, or 0s and 1s.
The second question is: you might say we use our language when dealing with computers every day, and we don’t use the binary language, so the computer understands us. Does this imply that the computer automatically converts data entered in our language into 0s and 1s? Exactly. But how?
If you speak to an Arab friend and you don’t know how to speak in Arabic and your friend doesn’t know how to speak English, then you need someone to translate. This translator knows how to convert Arabic into English, and vice versa.
This is the same case with the computer. There is a translator that translates your language into a binary language and vice versa. This translator is called a compiler. We will create a different course for compilers.
So, for this compiler to be able to translate your language to the binary language, it needs to know how to convert numbers, alphabets, special symbols, images, videos, and audio into zeros and ones. This is what we will see in this chapter.
1.1.2) How does a computer speak zeros and ones?
Now, we know that we must speak with the computer in zeros and ones, but the question is: how does the computer speak while it is inanimate? How do you find zeros and ones on an inanimate object?
Let’s conclude that.
What is the only thing that makes the computer work? Of course, electricity.
Is that to say that the data we see every day on your computer screen is just electricity? And the zeros and ones originally came from electricity?
Exactly. But how?
What is the only way by which you can use electricity? Of course, to use electricity, you will switch it on, and if you want to not use it, you will switch it off.
What if we denote 1 for on and 0 for off?
OK, that is fine, but if I switch the electricity off, the computer goes off.
Let me explain more.
We all know that there is a processing unit inside a computer called a CPU (central processing unit). This processing unit consists of billions of electrical circuits. Each circuit can be switched on or off by a component called a transistor. The sequence of on and off is the zeros and ones. The following image can show that.

What?! Does that mean there are no actual 0s and 1s moving inside the computer? ..In fact, no. They are just pulses of electricity with a certain voltage value resulting from the electric circuits that are switched on or off in a certain sequence to represent data. This is the way in which the computer speaks.
And in this chapter, we will talk about it also.
But there is a question. If the data is just electricity, this means when we switch the computer off, the data will be lost. But this is not what happens, because we find the data is stored on the hard drive even if we switch the computer off.
OK, that is right, but we have 2 different ways to represent data. One of them is using electricity, and when you switch the computer off, only the data on the RAM (Random Access Memory) is lost. Storing data on a hard drive uses a different method, which we will talk about in the course also.
So, in this chapter, we will see how to represent numbers, text, images, video, and audio into zeros and ones.