20 min read
Number Systems in Real Life
Hex colour codes, memory addresses, network addresses and Linux file permissions — where binary, octal and hex appear.
Hexadecimal Colour Codes
Screens make every colour by mixing red, green and blue light (RGB). Each of the three uses one byte: a value from 0 to 255. One byte is exactly two hex digits, so a colour is written as six hex digits after a #:
#RRGGBB — two digits for red, two for green, two for blue.
| Some colour codes | ||
|---|---|---|
Colour mixer (RGB)
Hex: #813588
rgb(129, 53, 136)
≈ CMYK 5% 61% 0% 47%
The CMYK figures use a simple formula. Real print conversion (for example in Photoshop) uses colour profiles, so the numbers will differ a little.
Memory Addresses
Every byte in memory has a numbered address. Addresses are large binary numbers, so they are shown in hex. The printer's error message 0x7F3A means address 7F3A₁₆ = 32,570₁₀. The 0x in front is the usual way programs mark a hex number.
Hex is shorter than binary and converts to it instantly: 7F3A₁₆ = 0111 1111 0011 1010₂. An engineer can see the exact bits at a glance.
Network Addresses
- A MAC address identifies a network card. It is six bytes written in hex, for example 3C:52:82:1A:9F:07.
- An IPv4 address such as 192.168.1.20 is four bytes written in decimal. Each part is 0–255 because each part is one byte. In binary, 192 is 11000000.
- The newer IPv6 addresses are written in hex because they are 128 bits long, for example 2001:db8::1.
Octal File Permissions in Linux
Linux and macOS give every file three sets of permissions — for the owner, the group and others. Each set has three yes/no switches: read (r), write (w) and execute (x). Three bits → exactly one octal digit.
| One octal digit = rwx | ||
|---|---|---|
Setting permissions on a Linux serverCommand line
chmod 750 customer-designsls -ldrwxr-x--- 2 nuwan staff 4096 Mar 12 09:15 customer-designsPractice
More lessons in Number Systems · Next: Presenting Conversions in a Report · Previous: Octal and Hexadecimal — and Choosing a Route
