All articles

Binary and Hexadecimal Explained: A Beginner's Guide

July 25, 202510 min read

Every digital device on earth—your phone, your laptop, a traffic light controller—stores and processes information as binary: sequences of 1s and 0s. This isn't an arbitrary convention. It's a direct consequence of how physical electronics work. A transistor is either on or off, a capacitor is either charged or not, a voltage is either high or low. Binary maps perfectly onto these two physical states. Understanding binary—and its close relative hexadecimal—gives you a foundation for understanding how computers actually represent data.

Positional Notation: The Same Principle Across All Bases

Every number system you'll encounter uses positional notation: the value of a digit depends on both the digit itself and its position in the number. You already use this every day in base-10 (decimal). In the number 4,276, the 4 represents 4 × 1,000 (10³), the 2 represents 2 × 100 (10²), the 7 represents 7 × 10 (10¹), and the 6 represents 6 × 1 (10⁰). Each position is a power of 10.

Binary (base-2) works the same way—but each position is a power of 2, and the only valid digits are 0 and 1. Hexadecimal (base-16) uses powers of 16, with digits 0–9 and A–F (where A=10, B=11, C=12, D=13, E=14, F=15). The underlying logic is identical across all three systems.

Binary to Decimal: Step-by-Step Conversion

To convert a binary number to decimal, write out each digit multiplied by its corresponding power of 2, then add them all up.

Example: convert binary 1011 to decimal. Reading right to left: 1 × 2⁰ = 1; 1 × 2¹ = 2; 0 × 2² = 0; 1 × 2³ = 8. Sum: 8 + 0 + 2 + 1 = 11. So binary 1011 = decimal 11.

Another example: binary 110101 = 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1 = 32 + 16 + 4 + 1 = 53. Use our Binary Calculator to verify conversions and perform arithmetic in binary.

Decimal to Binary: The Division Algorithm

To convert a decimal number to binary, repeatedly divide by 2 and record the remainders. Read the remainders bottom-to-top to get the binary result.

  1. Divide 45 by 2: quotient 22, remainder 1
  2. Divide 22 by 2: quotient 11, remainder 0
  3. Divide 11 by 2: quotient 5, remainder 1
  4. Divide 5 by 2: quotient 2, remainder 1
  5. Divide 2 by 2: quotient 1, remainder 0
  6. Divide 1 by 2: quotient 0, remainder 1
  7. Read remainders bottom-to-top: 101101

Verification: 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 32 + 8 + 4 + 1 = 45. ✓

Why Hexadecimal Exists: Compact Binary Representation

Binary is accurate but verbose. The number 255 in binary is 11111111—eight digits for a number that fits in two decimal digits. Hexadecimal was invented to give programmers a more compact way to represent binary data, because 16 = 2⁴. This means every single hex digit maps exactly to four binary digits (a nibble).

  • 0 in hex = 0000 in binary
  • 7 in hex = 0111 in binary
  • A (10) in hex = 1010 in binary
  • F (15) in hex = 1111 in binary

This makes the conversion between hex and binary trivial: replace each hex digit with its 4-bit binary equivalent, and you're done. The 8-bit value 11111111 (binary) becomes FF (hex)—two characters instead of eight. Use our Hex Calculator to explore hex arithmetic and conversions.

Practical Uses of Binary and Hexadecimal

Memory Addresses

Every byte in a computer's memory has a unique address. Modern 64-bit systems have address spaces requiring up to 16 hexadecimal digits—far more manageable than 64 binary digits. When a crash report shows an error at address 0x00007FF8A1BC3D40, that's a 64-bit memory address written in hex. The "0x" prefix is the conventional way to signal a hexadecimal number in code.

RGB Color Codes (#RRGGBB)

Web colors use a six-digit hex code: #RRGGBB, where RR, GG, and BB are each one byte (0–255) representing the intensity of red, green, and blue. The color #FF5733 means: red = FF (255), green = 57 (87), blue = 33 (51). Understanding hex makes it easy to read and manipulate colors in CSS, image editors, and design tools. Pure red is #FF0000, pure green is #00FF00, pure blue is #0000FF, and white (all channels maxed) is #FFFFFF.

Unix File Permissions

In Unix and Linux systems, file permissions are stored as three groups of three bits (read/write/execute for owner, group, and others). This 9-bit structure is typically expressed as an octal (base-8) number. The permission set rwxr-xr-- in binary is 111 101 100, which is octal 754. Understanding binary makes the logic of these permissions clear: each bit is literally an on/off flag for a specific capability.

Common Mistakes in Binary Arithmetic

  • Forgetting to carry: In binary addition, 1 + 1 = 10 (not 2). If you add 0111 + 0001, you must carry: the ones column gives 0, carry 1; the twos column gives 1+1=10, write 0 carry 1; and so on. Result: 1000.
  • Confusing signed and unsigned representations: In 8-bit signed representation, 11111111 represents −1, not 255. The leftmost bit is the sign bit in two's complement.
  • Skipping leading zeros: When converting hex to binary, each hex digit must produce exactly 4 bits, including leading zeros. Hex B = 1011, not just 11—the leading zeros matter when concatenating nibbles.
  • Using decimal intuition for overflow: In an 8-bit system, 255 + 1 wraps around to 0, not 256. Binary overflow behaves differently from decimal arithmetic.

Binary and hexadecimal underlie virtually every aspect of computing—from how your code is stored to how images are encoded to how your network traffic is addressed. Once positional notation clicks, both systems become as natural as the decimal arithmetic you've been doing since childhood. The only real difference is the base—and the base is just a choice about how many fingers to count on.

Continue exploring this topic

This article is part of our math guides and calculators collection.

For a related explanation, read How to Solve Any Triangle: Law of Sines vs. Law of Cosines: A triangle has six elements—three sides and three angles—and knowing just three is enough to find the rest. This guide shows when to use the Law of Sines versus the Law of Cosines, explains the ambiguous SSA case, and walks through worked examples for every scenario. Another useful perspective is Understanding Standard Deviation and Why It Matters: Standard deviation measures the spread of a data set—but most explanations stop there. This guide walks through the full calculation, the difference between population and sample formulas, the empirical rule, and practical uses in quality control, finance, and polling.