AlgoViz

Number bases (binary & hex)

easy 14 min

Every number base works the same way: each digit is multiplied by the base raised to the power of its position.

Where it shows up

The same pattern appears across everyday software.

  • Memory addresses and debuggers

    Debuggers, crash logs and pointer printouts show addresses such as 0x7FFF5FBFF8C0 in hex. Each hex digit is four address bits, so alignment and page boundaries are easy to see: an address ending in 000 is 4 KB aligned.

  • Web and design colours

    A CSS colour like #FF5733 is three bytes written as hex pairs: red 0xFF = 255, green 0x57 = 87, blue 0x33 = 51. Every channel runs from 00 to FF because one byte holds 0 to 255.

  • Unix file permissions

    chmod 755 is octal. Each digit is three bits for read, write and execute: 7 = 111 gives the owner rwx, 5 = 101 gives group and others r-x.

  • IP and MAC addresses

    An IPv4 address is four 8-bit octets written in decimal (192.168.1.1), and a subnet mask like 255.255.255.0 is 24 ones followed by 8 zeros. MAC addresses are six bytes in hex, such as 00:1A:2B:3C:4D:5E.

  • Bit flags and feature masks

    Permission systems, file open modes and game state pack many on/off options into one integer, one bit each: READ = 1, WRITE = 2, EXEC = 4. Combining with | and testing with & only makes sense once you read numbers in binary.

  • Hex dumps and file formats

    Tools like xxd and hexdump show raw bytes in hex, two digits per byte. File signatures are spotted this way: a PNG starts with 89 50 4E 47, and a PDF with 25 50 44 46, which is %PDF in ASCII.