Binary Code Cheat Sheet

Quick reference: powers of 2, ASCII codes, binary-to-hex, and common bit patterns

Powers of 2 (1 to 1024)

2⁰=1, 2¹=2, 2²=4, 2³=8, 2⁴=16, 2⁵=32, 2⁶=64, 2⁷=128, 2⁸=256, 2⁹=512, 2¹⁰=1024. Memorize through 2⁸ for 8-bit binary work. Knowing these values is the difference between reading binary in seconds versus minutes.

Common ASCII Codes

Space=32 (00100000), 0-9 = 48-57 (00110000-00111001), A-Z = 65-90 (01000001-01011010), a-z = 97-122 (01100001-01111010), Newline=10 (00001010), Tab=9 (00001001), Period=46 (00101110), Comma=44 (00101100). Tip: uppercase starts with 010, lowercase with 011, digits with 0011.

Binary ↔ Hex Conversion

One hex digit = 4 bits: 0000=0, 0001=1, 0010=2, 0011=3, 0100=4, 0101=5, 0110=6, 0111=7, 1000=8, 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F. To convert binary to hex: group bits into 4s from the right, convert each group. 11011010 → 1101=D, 1010=A → 0xDA. Hex is vastly easier to read and write than raw binary.

Data Size Reference

1 bit = single 0 or 1. 1 byte = 8 bits (256 values). 1 KB = 1024 bytes (~1 page of text). 1 MB = 1024 KB (~1 novel). 1 GB = 1024 MB (~1 movie). 1 TB = 1024 GB (~1,000 movies). These are binary (base-2) units — storage manufacturers sometimes use decimal units (1 KB = 1000 bytes) which causes the "missing space" phenomenon on hard drives.

Quick Reference: Common Bit Patterns

00000000=0, 11111111=255, 10101010=170, 01010101=85, 10000000=128, 01111111=127, 11110000=240, 00001111=15. When debugging binary data, these patterns are visual anchors. Seeing 10101010 in a hex dump usually means uninitialized memory or a test pattern.