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.
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 5 | 0101 | 5 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
| 255 | 11111111 | FF |
| 256 | 100000000 | 100 |
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 decimalHow 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 decimalOne 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.
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.
PLUS DE GUIDES
jsonb64rxjwthashmd
Voir tous les outils Développeur →Qu'est-ce que JSON ?
Un guide complet sur la syntaxe JSON, les types de données et les cas d'utilisation courants.
Qu'est-ce que Base64 ?
Comment fonctionne l'encodage Base64, pourquoi il existe et quand l'utiliser.
Tutoriel sur les expressions régulières
Apprenez les expressions régulières depuis zéro avec des exemples pratiques.
JWT : définition et fonctionnement
Comment fonctionnent les jetons JSON Web, leur structure et comment les utiliser en toute sécurité.
Fonction de hachage : définition et exemples
Comment fonctionnent les fonctions de hachage, à quoi servent MD5, SHA-1 et SHA-256, et pourquoi certains ne sont plus sûrs.
Guide Markdown
Une référence complète de la syntaxe Markdown — titres, listes, liens, blocs de code, tableaux, et plus encore.