Number Systems: Binary Octal Hexadecimal Easy Explanation
Humans count in tens because we have ten fingers, but computers count in twos because a wire is either on or off. Binary uses only the digits 0 and 1, and every photo, song, and document in a computer is stored as patterns of these two digits. Learning binary is the first step to understanding how machines think.
Octal (base 8) and hexadecimal (base 16) are shorthand systems that make long binary strings readable. A memory address like 1011010001110000 in binary is painful, but as B470 in hexadecimal it fits four characters. Programmers meet hex daily in colour codes, addresses, and error codes.
Key Concepts
- Base (radix): the digit count: binary 2, octal 8, decimal 10, hexadecimal 16.
- Place value: each position is a power of the base. In 10112 the places are 8, 4, 2, 1, giving 8 + 2 + 1 = 11.
- MSB and LSB: most significant bit (leftmost) and least significant bit (rightmost).
- Bits, nibbles, bytes: 1 bit, 4 bits, 8 bits. A byte holds 0 to 255.
- Hex digits: 0–9 plus A, B, C, D, E, F for 10–15.
- Subscripts: the base written small, e.g. 10112, 2D16, avoids confusion.
Formulas
- Binary to decimal: sum each bit × 2position, positions counted from 0 at the right.
- Decimal to binary: repeatedly divide by 2; remainders read last-to-first give the binary number.
- Binary to octal/hex: group bits in threes (octal) or fours (hex) from the right, one digit per group.
- Range: n bits hold 2n values, 0 to 2n − 1 unsigned.
Worked Example
Convert decimal 45 to binary, then hexadecimal, and verify.
- Divide by 2 repeatedly: 45→22 r1, 22→11 r0, 11→5 r1, 5→2 r1, 2→1 r0, 1→0 r1. Remainders bottom-up: 1011012.
- Verify: 32 + 8 + 4 + 1 = 45. Group in fours: 0010 1101 = 2D16. Check: 2 × 16 + 13 = 45.
Common Misconceptions
- Hex is harder than binary. It is easier for humans: one hex digit labels four bits, so nobody reads 32-bit addresses in raw binary.
- 10 always means ten. It means one base plus zero: two in binary, eight in octal, sixteen in hex. Always note the base.
- Leading zeros change the value. They do not; 001012 is still 5. They only fill groups for conversion.
Real-World Applications
- Web colours are hex, e.g. #FF5733, with digit pairs for red, green, blue.
- Debuggers and machine code display addresses and values in hexadecimal.
- Linux file permissions use octal, as in chmod 755.
- IPv6 addresses and MAC addresses are written in hexadecimal groups.
To recap: binary is the machine's language of 0s and 1s; octal and hexadecimal group bits in threes and fours for human readability. Convert with place values one way and repeated division the other, and always label the base.
Related blogs
- Binary Arithmetic and Complements: Addition to 2's
- Boolean algebra and De Morgan's theorems Explained with
- Logic Gates and Universal Gates Explained in Simple Words
- Combinational Circuits: Adders, Multiplexers And More
- Sequential Circuits: SR, JK, D and T Flip-Flops Explained
- Counters and Shift Registers: Working and Types Explained