Every number you work with — whether it's a color code, a memory address, a file permission, or a network mask — can be expressed in different bases. The number 255 in decimal is FF in hexadecimal and 11111111 in binary. They're the same value, just written in different numbering systems.
Understanding number bases isn't just academic — it's a daily reality for developers, system administrators, network engineers, and electronics enthusiasts.
Convert Between Any Number Base
Number Base Converter
Convert any number between binary, octal, decimal, and hexadecimal bases instantly with input validation and one-click copy.
The Four Common Number Bases
Base 10 — Decimal (the one humans use)
Uses digits 0–9. This is what we use in everyday life because humans have 10 fingers.
Base 2 — Binary (the one computers use)
Uses only 0 and 1. Every piece of data in a computer is ultimately stored and processed as binary — electrical signals that are either on (1) or off (0).
Base 16 — Hexadecimal (compact binary representation)
Uses digits 0–9 and letters A–F (representing 10–15). One hex digit represents exactly 4 binary digits (a "nibble"), and two hex digits represent a full byte. This makes hex a compact, human-readable way to write binary data.
Base 8 — Octal (used in Unix permissions)
Uses digits 0–7. Less common today, but still relevant in Unix/Linux file permissions (chmod 755) and some hardware contexts.
The Same Number in All Four Bases
| Decimal | Binary | Hexadecimal | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 10 | 1010 | A | 12 |
| 16 | 10000 | 10 | 20 |
| 42 | 101010 | 2A | 52 |
| 255 | 11111111 | FF | 377 |
| 256 | 100000000 | 100 | 400 |
| 65535 | 1111111111111111 | FFFF | 177777 |
Where Each Base Is Used in Practice
Binary — CPU instruction sets, bitwise operations, network masks, flags. When you see code like if (flags & 0b00000100), that's binary masking to check a specific bit.
Hexadecimal — Memory addresses (0x7FFE4A20), color codes (#FF5733), MAC addresses (A4:C3:F0:85:7D:3B), SHA hash values, UUID components, bytecode, and assembly language.
Octal — Unix file permissions. chmod 755 means owner can read/write/execute (7 = 111 binary), group can read/execute (5 = 101 binary), others can read/execute. Each permission group is a 3-bit binary number — perfectly represented by one octal digit.
Decimal — Everything else humans interact with directly: port numbers, line numbers, timestamps, UI values.
How to Convert: The Manual Method
Decimal to Binary
Divide by 2 repeatedly, record remainders from bottom to top:
42 ÷ 2 = 21 R 0
21 ÷ 2 = 10 R 1
10 ÷ 2 = 5 R 0
5 ÷ 2 = 2 R 1
2 ÷ 2 = 1 R 0
1 ÷ 2 = 0 R 1
Reading remainders bottom-up: 101010 ✓
Binary to Hexadecimal
Group bits into sets of 4 from the right, convert each group:
Binary: 1010 1111 0011
Hex: A F 3
Result: 0xAF3
Hexadecimal Color Codes
A CSS hex color #FF5733 is three hex pairs:
FF= 255 red (maximum)57= 87 green33= 51 blue
Bit and Byte Reference
| Term | Size | Max Value (unsigned) |
|---|---|---|
| 1 bit | 0 or 1 | 1 |
| 1 nibble | 4 bits | 15 (0xF) |
| 1 byte | 8 bits | 255 (0xFF) |
| 2 bytes (word) | 16 bits | 65,535 (0xFFFF) |
| 4 bytes (dword) | 32 bits | 4,294,967,295 (0xFFFFFFFF) |
| 8 bytes (qword) | 64 bits | 18,446,744,073,709,551,615 |
In Programming Languages
Most languages support literal values in multiple bases:
# Python
decimal = 42
binary = 0b101010 # prefix 0b
octal = 0o52 # prefix 0o
hex_val = 0x2A # prefix 0x
# All equal 42
print(decimal == binary == octal == hex_val) # True
// JavaScript
const dec = 42;
const bin = 0b101010;
const oct = 0o52;
const hex = 0x2A;
// Convert to other bases:
(42).toString(2) // "101010" (to binary)
(42).toString(16) // "2a" (to hex)
parseInt("FF", 16) // 255 (hex string to decimal)
Frequently Asked Questions
Why do computers use binary instead of decimal?
Electronic circuits have two stable states: on and off, high voltage and low voltage. Binary maps directly to these two states. Decimal would require 10 distinct voltage levels, which is impractical and error-prone in hardware.
What does the 0x prefix mean?
It's a convention signaling that the following value is in hexadecimal. 0xFF means "FF in hex" = 255 decimal. Similarly, 0b = binary and 0o = octal in most languages.
How do negative numbers work in binary?
Two's complement is the standard system. To negate a number: flip all bits, then add 1. In an 8-bit system, -1 is represented as 11111111. This is why signed 8-bit integers range from -128 to +127 while unsigned 8-bit integers range from 0 to 255.
Why is hexadecimal preferred over binary for reading memory?
Binary is too verbose — the memory address 0x7FFE4A20 would be 32 binary digits. Hex is 8 characters and maps directly (each hex digit = 4 bits), making it compact and still easy to convert mentally.
Does FluxToolkit store my number conversions?
No. All conversions run in your browser. Your inputs never leave your device.
Related Articles
- Base64 Encode and Decode: A Complete Developer's Guide — Another encoding system developers encounter constantly.
- URL Encoding and Decoding Explained — Percent encoding uses hex values for unsafe URL characters.
- SHA-256 vs MD5 vs bcrypt: Which Hashing Algorithm? — Hashes are typically displayed in hexadecimal.