This article is one of the three serious articles that talk about Data. This is the first one. You can find the second here and the third here.

In one of my previous articles, when I tried to define what programming means, I talked about computers and what they do. I also talked a little about how they represent numerical values. This article will elaborate more and make you understand what data is, how we measure it, and how we represent numbers in computer memory. So, without further ado, let's get into it.

Let's start by defining what Data means. Data is nothing but some value that can be recorded in digital form. Data can be as simple as our names or ages. It can also be as complicated as graphs, charts, and maps. Simply put, Data is a symbolic representation of something in the real world on to computer's memory.

Data Types

When we say some value that can be recorded digitally, the above definition clearly shows us that there are different forms of data. What I mean by that is, we don't represent names and numbers in the same format, right? They both have other representational structures. Names use alphabetic characters like A - Z or a - z, while ages use decimal characters like 0 - 9. Like wise, computers also have a different form of representation called Data Type that will answer its form. It will answer the questions like, is it a number or a string or some other format?

Now, the thing what I don't want you to get confused about is that different programming languages use various forms of data types. For example, in C++, the number 2 is represented as an integer. In contrast, 2.0 is described as a floating-point number. Still, they both fall into the same category called numbers when it comes to Python. One thing to note here is that, in computers, the actual representation of data remains as numbers, which means in a binary number representation; What really differentiates the form of Data is how much memory size we need to store it. Let's talk about how we measure data in computers to understand this.

How do we measure data in computers?

As we understood in this article, everything in the computer is 0s and 1s; We also saw an example representing a decimal number 8 as 111. So, to measure data in a computer, the 0s and 1s are our basis. I mean that 1 single position in a string of 0s and 1s is called Bit. To represent a decimal number 8, we need 3 positions meaning 3 Bits, that is 111. Simple, right?

The question is, how do we measure more significant numbers like thousands or even higher? If we need 3 strings of 0s and 1s to represent just a number 8, imagine how long it will be to represent a higher number. That's where we will come to Bytes (described as B). Bytes are the basic measurements of data in the computer. Bytes means simply 8 positions of the 0s and 1.

Suppose a value is more extensive than 1 Byte (i.e., 8 positions); we move on to the next one, that is Kilo Bytes (KB). 1 Kilo Byte means 1024 Bytes strung together (if you would like to calculate it in terms of bits, it will be 1024 * 8 Bits). Then we will advance to Mega Bytes (MB), then Giga Bytes (GB), then Tera Bytes (TB), then Peta Bytes (PB), then Exa Bytes (EB), then Zetta Byte (ZB), then Yotta Byte (YB). Look at the following table for your references.

Unit NameValue
BitEither 0 or 1
Byte (B)8 bits
Kilobyte (KB)1,024 B or 8,192 Bits
Megabyte (MB)1,024 KB or 1,048,576 B
Gigabyte (GB)1,024 MB or 1,073,741,824 B
Terabyte (TB)1,024 GB or 1,099,511,627,776 B
Petabyte (PB)1,024 TB or 1,125,899,906,842,624 B
Exabyte (EB)1,024 PB or 1,152,921,504,606,846,976 B
Zetta Byte (ZB)1,024 EB or 1,180,591,620,717,411,303,424 B
Yotta Byte (YB)1,024 ZB or 1,208,925,819,614,629,174,706,176 B

Let's assume we have 516 GB of memory; what will it be in KB, MB, and TB? Well, we just have to do the Maths. Let's start from the higher one and work our way down to the smallest one:

516 GB = (516 / 1024) TB = 0.504 TB
516 GB = (516 * 1024) MB = 528,384 MB
516 GB = (516 * 1024 * 1024) KB = 541,065,216 KB

Note: To get the value on TB we divided but for the other we multiplied, the reason is TB is bigger than GB.

By now, I think you understand why we mention the size of a storage media (which we will talk about after this serious has ended) when we consider buying one. The higher it is, the more data we can store on it.

The trickiest part is this, how do we represent real-world value in a computer? Data cannot be entered and processed directly into computers using human language since computers only speak the binary language. To answer this, let's see how we represent numbers in computers in this article, and we will move on to the other forms of data in the upcoming articles.

How do we represent Numbers?

Let's an example of how much size we need to store a number 679. As discussed in the previous article:

(679)10 = (1010100111)2

That means, we need 10 positions. Since Bytes are our primary memory measuring unit, the number 679 requires 2 Byte (16 Bits) memory size.

How about 102,436,895,731,945?

(102,436,895,731,945)10 = (10111010010101001110010110010000011000011101001)2

Right? (If you don't trust me, convert it by the methods we discussed in this article). This means we need 47-bit positions. To convert to Bytes, we have to divide it by 8, which gives us 5.875. Since we don't have the so-called 5.875, we will upgrade it to the closest higher integer number 6. So we need 6 Bytes. That's how we represent positive integer numbers in computer memory.

What about negative and floating point representations? We will not cover them in this article since the concept itself requires the whole article, and we don't need them unless we want to design circuits. Knowing the basics is enough for our programming journey. Still, if you wish to extend your knowledge, you can read more about it in this great article.

The following article will talk about how we represent texts on computers.