Digital Systems
What exactly is a computer?
Before diving into the world of programming, it's worth reflecting on how these machines work. They're powered with electricity and they can only understand binary code (0s and 1s), but how does this magic happen? A computer is an electronic device made up of digital circuits, but that doesn't mean everything digital, like a simple calculator, is a computer, does it? A simple calculator, for example, isn't a computer because it's not programmable — this is where you as a programmer join the picture! We develop code to run on it! But... how does electricity represent information? how do 0s and 1s go beyond numbers? how do these elements enable the complex operations we see in computers today?
Electric Signals
We're sure you've heard about digital and analog signals... Can you guess what type of signals are used in computers? Digital signals can only have two states: on (1) or off (0). Analog signals, on the other hand, are continuous and can take any value (like sound waves)! One of the key benefits of digital communication is it's resistance to noise interference. While noise can significantly disrupt analog signals, digital signals remain relatively unaffected, as it is easy to distinguish between a 0 and a 1, even in the presence of considerable noise making them perfect for computers to process data accurately!

digital & analog signals
Number systems
Why do computers use sequences of 0s and 1s to store and process information, and how do they do it? Computers process information using digital electrical signals, which have two distinct states: 0 and 1. These binary states align with the binary system, a base-2 numeral system, where all values are represented using only these two digits. In contrast, the numeral system most of us are familiar with is the Hindu-Arabic system which is base-10, meaning it uses ten digits (0-9) to represent values. This system is natural for humans because we have ten fingers, making counting in tens intuitive. The reason computers use the binary system is that digital circuits are designed to easily distinguish between two states, such as "on" and "off," or "true" and "false." Each 0 or 1 in binary is known as a bit, the smallest unit of data in computing. By combining groups of bits, larger values can be represented. Just like the decimal system, binary follows the same basic principles, where the position of each digit corresponds to a power of 2. It might sound a bit basic, but it's the backbone of everything computers do. Bits are the building blocks of binary code, allowing computers to store and process information. It's pretty surprising how these two simple values, 0 and 1, can represent all kinds of complex things like images, music, and videos! Although computers use binary for processing, hexadecimal (base-16) is often used by humans as a shorthand to represent binary data in a more compact and readable way. Hexadecimal makes it easier for programmers and engineers to work with large binary values because one hexadecimal digit corresponds to four binary digits, simplifying the representation of long binary numbers.
Decimal (Base 10) | Binary (Base 2) | Hexadecimal (Base 16) |
---|---|---|
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
10 | 1010 | A |
11 | 1011 | B |
12 | 1100 | C |
13 | 1101 | D |
14 | 1110 | E |
15 | 1111 | F |