Bit stands for Binary Digit. There are only two binary digits i.e. 0 and 1.
Our mathematics starts from 0 and ends at 9. Then we take the first number “0” and put the next number before it “1”. It gives us 10 and then we count again from 0 to 1 and reach 19, then we change the first digit again.
But, for computers, there are just two numbers i.e. 0 and 1. So, if they have to count, they’ll have to use only these two numbers. They start with “0” and then proceed to “1”. After that, they take 0 again just like us, and put the 1 behind it. The third number becomes 10 and the fourth becomes 11. Again, because the numbers are finished, we take two 0’s and put 1 behind it.
This is how computers calculate things. Everything inside computers is represented, calculated, manipulated, stored, and processed in the form of numbers.
For example, to store a picture, the computer has to check each pixel and its color. The color is then converted into a binary code (typically RGB values) and stored inside the temporary or permanent memory. This is done for each pixel and this can easily become hundreds of thousands of bits for a single picture depending on its size. If the system has to store it, the request is sent to the permanent storage drive (SSD or HDD) along with the address of the location so that it can be retrieved when demanded.
What is a bit?
Bit is the smallest unit of data a computer can work with. It could either be 0 or 1. Whether it is a music file, video file, text file, or image file, everything is understood, processed, stored, and edited by the computer in the form of bits. There are different conversion methods for different files but, at the end of the day, there are huge numbers of bits representing even very small files in our computers.
The output devices like our monitor get the color signal in the form of bits as well. The input devices like the mouse send the movement signals taken through the light in the form of bits. The CPU processes everything in the form of bits but we can’t see how it is happening with our eyes. The scale of operation even for a little mouse movement is pretty huge. The difference in position must be sent to the CPU and it should then send the same signal back to the monitor. Leave aside the complexity of doing tasks like video editing.
However, for the computer, it is just a large circuit that turns On and Off at different points. Billions of these points are present in a single CPU and each is controlled by a complex system just to give the software a platform to run.
For humans to understand and work with these circuits, bits are like abstractions. Older computers used to work with the help of physical switches where we turned the switches on and off with our hands.
But, as the technology advanced, we added a layer of software to make programming the computers easier. If you have to program a computer from its very basics, you must understand the machine code. A machine code is converted into binary bits and then the processing is done as per the commands. But, because we have the operating system and then many software for different works, we don’t really know what is going on under the hood. We will talk about the role of software later on.
Example Machine Code (Human Language) converted into bits (Computer Language)
Let’s write a machine code to add two digits. Let’s then convert it to bit form so that we can understand how computers understand humans and do their job.
Our code has a simple instruction ‘Add A,B‘. This instruction means the computer will add the value stored in register A and register B.
The ADD instruction here also has its own binary Opcode i.e. 0001. The Opcode for indicating Register A is 01 and B is 10.
So, when we put all these instructions into the binary code, it will become 0001 01,10
The CPU now knows that the 0001 commands indicate addition logic. It will then check the next numbers i,e, 01, and 10. The full machine code in the binary form will become 0001 0110.
The CPU reads the binary sequence 0001 0110, decodes it as an ADD operation involving registers A and B, and then performs the addition.
Just like this, big programs are run but everything will be converted into the bit form first of all.
Why only two bits?
Computers work with the help of electronic circuits. To solve any problem or run a command, the computer must have some kind of logic. For example, to add 1 to another 1, there must be a circuit that can create 2 as the output. For this, we can create a circuit that takes two inputs in the form of high or low voltage. Depending on that input, we can design the circuit to give one or two outputs. The circuits are designed in a way that we can manipulate them with the help of a code (called software). The circuits are always already designed.
The purpose of using two bits is to use the power of electronics for doing calculations with the highest level of accuracy.
An electric circuit can be turned On or Off at a time. So, we just get two different levels of values which can be represented as On/Off, High/Low, or +/-.
For example, if a circuit gets some input or inputs as 0s and 1s or high/low voltage, the resulting values can be interpreted in the same manner. A single circuit can be designed in a way that it gives different values based on the input values. It could give 1 as output with “0 0” as input or 0 as output with “1 1” as output. There is a master clock that can be used to feed different circuits get outputs and then give inputs from other outputs.
The issue is that we just have two values and this makes our circuits big yet simple. We may have to work with thousands of bits at a time but because there are only two values, the speed of operation and accuracy increase a lot.
Physical Representation of a Bit
Bits are only in our minds. There is no actual 0 and 1 inside our CPU. There is only current flowing in all directions and there are circuits either allowing or blocking this flow. The physical representation of bits is different in different computer components.
CPU mainly uses the state of transistors i.e. On or Off to represent the bits. If we have to add two bits, there must be some operations inside the transistors.
Inside the RAM, bits are stored mainly in the form of electric charge inside the capacitors.
Inside the SSDs, the bits are stored in the form of electric charge in floating gate transistors. Each floating gate transistor can hold more than one bit as well.
Inside the hard drives, there are magnetic domains representing the values of the bits 0 or 1.
In optical drives like DVDs, CDs, etc, the bits are represented in the form of pits and land on the surface of the disk.
So, there are all the methods to represent a bit so that we can interpret it for our benefit. All these storage mediums must also be able to interact with the CPU and with each other as well. The faster the speed of this interaction, the lower will be the bottlenecks.
CPU is the brain controlling everything from the processing to storing the data. Inside the CPU, bits are just the voltage levels inside transistors. These transistors function as switches that can either allow or block the flow of electrical current. When a transistor is “on,” it allows current to pass through, which is typically interpreted as a binary 1. When it is “off,” it blocks the current, which is interpreted as a binary 0.
- High Voltage: Represents a binary 1.
- Low Voltage: Represents a binary 0.
The exact voltage levels depend on the technology used (e.g., CMOS, TTL), but the principle remains the same: distinct voltage thresholds define the 0 and 1 states.
How does the computer’s do calculations using 0s and 1s?
Computers use logic gates to do their jobs. Logic gates are made up of electronic components such as MOSFETs, BJTs, diodes, resistors, capacitors, power supplies, etc. In digital electronics, these operations are called AND, OR, NOT, NAND, NOR, XOR, and XNOR operations.
We don’t have to go very deep into this but I will give you a brief idea of how the calculations or processing is done inside the computers.
The CPU is the central processing unit. It processes the data, changes it, stores it, sends it, and does many things with it. There is a memory alongside the CPU that helps with the processing. Each operation is done in a four-step cycle called Fetch, Decode, Execute, and Store. This starts with fetching the information from the memory, decoding the instruction, and understanding the action. The necessary action is done and the result is stored back in the memory.
All these instructions along with the data to be processed and data to be stored are in binary form. It means, that whatever the thing you are doing on your computer is converted into the sets of data in the form of actual data and the instruction all in binary digits.
However, all the calculations and operations adhere to the very popular mathematics concept called Boolean algebra. With the help of logic gates combined with boolean algebra, we can do things like additions, subtractions, multiplications, etc.
A basic mathematical calculation in binary is like this:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 10 (which is 0 with a carry of 1 to the next bit).
Now, these numbers can be converted into different steps but at last, all comes down to the basic logical operations like this.
Role of software
It is impossible to understand how computers work without knowing the software. A computer without software is just like a big circuit ready to do things. It just waiting for the commands to do anything. This command must be in the binary form as well. But, we interact with the computers with the help of programming. We use high-level languages to give instructions to computers but the computer first converts them to binary which is its language.
We generally think there are things that a computer does on its own and there are things that we tell it to do. But, there is nothing a computer can do on its own. Everything from mouse movements to booting is controlled and done by the software. Hardware is like a giant circuit that can be programmed with the help of the software.
The same CPU can be used to play games, edit videos, and run Google Chrome. How is that possible? This is happening because the CPU serves as a big network of programmable circuits. Each pixel on your display gets its signal from the computer. Each mouse movement changes the color of your display in the same arrow shape.
We think we are typing texts only on the monitor. But, the computer is changing the white pixels to the black pixels. The text editor like Microsoft Notepad provides you with a white space and you are typing on it. The input values from the keyboard go to the CPU first and then it shows on the notepad. But, for Notepad to work, there is another layer of the operating system that interacts with the hardware in real time.
Role of bits in CPU operations
CPU performs what is called bitwise operations. These operations are done with the help of logic gates such as AND, OR, XOR, and NOT. All the data processed by the CPU whether characters, numbers, and instructions is represented in bits. The CPU reads this data from the memory and do the necessary operation as given in the instructions. It can then write the result back into the memory.
The CPUs work along with small memory locations called Registers. These registers hold the temporary data which is required for anything that the CPU is doing. Each register can hold a set of bits typically 32-bits and 64-bits.
There are control signals in the CPU that are also represented in the form of bits. Their role is to direct the flow of data between different parts of the CPU.
Role of bits in memory and storage
As we discussed above, everything is processed in the form of bits in the computer. Also, everything is stored in the form of bits as well. There are just high and low levels of voltage that discriminate the 0 and 1 values. In the memory or RAM of your computer, the bits are stored inside capacitors and retrieved by the CPU from there. RAM is the nearest and fastest type of memory for the CPU after the registers. But, it generally has a bigger capacity than the registers. So, the things that aren’t necessary in the registers anymore are sent to the memory. But, everything is sent in the form of bits and the RAM clears them as soon as the power is turned Off.
In permanent storage like SSDs, Hard Drives, Flash drives, etc, the bits are stored in places where they can stay without the need for power. Inside the SSDs, flash drives, external SSDs, and SD cards, the data is stored in the NAND flash memory. This is permanent memory that uses the floating gate transistors. However, in hard drives, the data is stored in magnetic platters in the form of different magnetic fields.
Because the CPU works with the bits, memory, and storage keeps them in a way that the CPU can use them whenever required. In the same way, the CPU can send the data in the form of bits to these storage mediums.
Conclusion
Understanding the concept of bits is important to know how computers work. However, there is no serious need to know this unless you are going to work as a hardware designer, driver developer, operating system programmer, etc. Bits is a very important concept in digital electronics. I hope I have given you a basic idea of what these bits are.