Bits and Bytes
Bit
Switch
We press a switch to turn a light on or off. When the switch is turned on, electricity flows and the light turns on, and when the switch is turned off, electricity doesn’t flow and the light turns off.

Digital devices such as Arduino, Raspberry Pi, and computers can perform various and complex tasks, but their fundamental operating principle is the same as turning a light on and off with a switch. The only difference is that they operate a very large number of switches at extremely high speeds. Today’s computer CPUs contain billions of transistors (switches) and can turn switches on or off billions of times per second.
Data Representation
So how is it possible to write documents, browse the internet, or watch videos simply by turning switches on and off?
Computers interpret the “on” state of internal switches as 1 and the “off” state as 0. Therefore, computers can only use 0 and 1 to represent any data, which is called binary.
Here, one digit of binary (0 or 1) is called 1 bit. For example, the decimal number 3 is 11 in binary and has two digits, so it is 2 bits.
The numbers that can be represented with 2 bits are as follows, totaling 4 numbers (22):
Binary | Decimal |
---|---|
00 | 0 |
01 | 1 |
10 | 2 |
11 | 3 |
Therefore, the number of values that can be represented with n bits is 2n.
In this way, computers represent all data such as numbers and characters using binary with 0s and 1s, and can perform various and complex tasks using this data.
Byte
Why It’s Used
As explained earlier, various data can be represented using bits, but computers do not use bits as the unit for data processing. Since data varies in size such as 6 bits, 17 bits, 196 bits, etc., the CPU would need to access data addresses bit by bit to read bits individually, requiring frequent operations.
However, it’s inefficient because the CPU needs to read or write 6 times to process one small number.
Instead, computers process data in 8-bit groups, which is called 1 byte. By using 8 bits as the minimum unit, some unnecessary bits may be added in certain cases, causing capacity waste, but it has the advantage of very efficient and fast processing.
Hex Code
Since byte values processed by computers are inconvenient for humans to read when displayed in binary, Hex code (hexadecimal value) is the value displayed using hexadecimal. Since 1 byte can be displayed with 2-digit Hex code, bytes can be efficiently represented. Hex code is usually prefixed with 0x to indicate that it is hexadecimal.