UTILYARD
Ce guide n'est disponible qu'en anglais.
guides

Binary, Hex, and Decimal Explained

How number systems work, how to convert between binary, hexadecimal, and decimal, and where each is used in programming.

Number systems overview

A number system is defined by its base — how many unique digits it uses before rolling over. Decimal (base-10) uses 0–9. Binary (base-2) uses 0–1. Hexadecimal (base-16) uses 0–9 and A–F.

DecimalBinaryHex
000000
100011
501015
101010A
151111F
161000010
25511111111FF
256100000000100

How binary works

Each binary digit (bit) represents a power of 2, from right to left:

Binary: 1 0 1 1 0 1
         ↓ ↓ ↓ ↓ ↓ ↓
Power: 2⁵ 2⁴ 2³ 2² 2¹ 2⁰
        32  16  8   4   2   1

= 32 + 0 + 8 + 4 + 0 + 1 = 45

So 101101 in binary = 45 in decimal

How hexadecimal works

Hex uses base-16. Each hex digit represents a power of 16. Letters A–F represent 10–15:

Hex: 2 F A
      ↓  ↓  ↓
    16² 16¹ 16⁰
    256  16   1

= (2 × 256) + (15 × 16) + (10 × 1)
= 512 + 240 + 10
= 762

So 0x2FA in hex = 762 in decimal

One hex digit = exactly 4 binary digits. This is why hex is so useful: FF in hex = 11111111 in binary = 255 in decimal. Two hex digits always represent one byte.

Where each is used

Binary: CPU instructions, bitwise operations, file formats at the byte level, network protocols
Hexadecimal: Color codes (#FF5733), memory addresses, error codes, file signatures (magic bytes), MAC addresses, SHA hashes
Octal (base-8): Unix file permissions (chmod 755), legacy systems
Decimal: Everything humans interact with directly — money, measurements, user-facing numbers
Number Base Converter
Convert between binary, decimal, hex, and octal instantly.
Open tool →

Frequently asked questions

Why do computers use binary?
Because electronic circuits have two stable states: on (1) and off (0). It's physically easier and more reliable to distinguish between two states than ten. All the complexity of modern computing — images, video, AI — is ultimately billions of on/off switches operating very fast.
What is a bit, byte, and word?
A bit is one binary digit (0 or 1). A byte is 8 bits (can represent 0–255). A word is architecture-dependent: typically 32 bits (4 bytes) on 32-bit systems and 64 bits (8 bytes) on 64-bit systems. A kilobyte is 1,024 bytes (not 1,000 — because 2¹⁰ = 1,024 is the convenient binary boundary).
Why is hex used for color codes?
An RGB color has three channels (red, green, blue), each 0–255. In hex, 0–255 maps to 00–FF — exactly two hex digits per channel. So a full color fits in 6 hex digits (#RRGGBB). It's compact, human-readable for developers, and maps directly to the underlying byte structure.
Binaire, hexadécimal et décimal expliqués — UtilYard