Value Converter
Free Number Base Converter Online
Convert numbers between binary (base 2), octal (base 8), decimal (base 10) and hexadecimal (base 16) instantly.
What is a number base — and why do computers care?
A number base, or radix, is the number of distinct digits a positional numbering system uses to represent values. The decimal system you use every day has a base of 10 — it uses the digits 0 through 9. When you exhaust all single digits and count past 9, you carry over to the next column and start again. The value of each column is a power of 10: ones, tens, hundreds, thousands, and so on.
Computers work at the hardware level with transistors that have exactly two stable states — on and off, represented as 1 and 0. This makes binary (base 2) the natural language of computing hardware. Every piece of data your CPU processes — text, images, video, code — is ultimately stored and manipulated as sequences of binary digits (bits).
While binary is what the hardware speaks, humans find long strings of 0s and 1s impractical to read and write. That's where hexadecimal and octal come in as shorthand representations that map cleanly onto binary without conversion ambiguity. Understanding how to move between these bases is a fundamental skill for systems programmers, network engineers, embedded developers, and anyone who reads compiler output or debugger disassembly.
Binary, octal, decimal and hexadecimal — a practical comparison
Each base has a distinct domain where it appears most naturally in modern computing and engineering:
| Base | Name | Digits | Typical use | Prefix |
|---|---|---|---|---|
| 2 | Binary | 0–1 | CPU instructions, file storage, flags, network protocols | 0b |
| 8 | Octal | 0–7 | Unix file permissions (chmod), some legacy protocols | 0o or 0 |
| 10 | Decimal | 0–9 | Human-readable numbers, display values, user input | None |
| 16 | Hexadecimal | 0–9 A–F | Memory addresses, colour codes, byte dumps, hash values | 0x or # |
The same integer — let's use 255 — looks completely different in each base: decimal 255, hex FF, octal 377, binary 11111111. They all represent exactly the same value. Knowing how to move between these representations is essential when reading memory dumps, writing bitfield operations, configuring permissions, or parsing network packets.
How number base conversion works — the algorithm
Any base → decimal
To convert a number from any base to decimal, multiply each digit by its base raised to its positional power (starting at 0 from the right), then sum the results. For binary 1011:
For hexadecimal 2F where F = 15: (2 × 16¹) + (15 × 16⁰) = 32 + 15 = 47.
Decimal → any base (repeated division)
To convert a decimal number to another base, repeatedly divide the number by the target base and collect remainders in reverse order. To convert 47 to hexadecimal: 47 ÷ 16 = 2 remainder 15 (F), then 2 ÷ 16 = 0 remainder 2. Reading remainders bottom-up: 2F. This works for any base.
Binary ↔ Hexadecimal (shortcut)
Because 16 = 2⁴, each hexadecimal digit maps exactly to a group of 4 binary bits (a nibble). This makes binary-to-hex conversion trivial without going through decimal: split binary digits into groups of 4 from the right, convert each group directly. Binary 1010 1111 → A + F → AF. This relationship is why hex is so prevalent in computing — it's compact binary.
Where each base appears in real-world development
Binary in bitwise operations
Bitwise operations (AND, OR, XOR, NOT, shifts) operate on individual bits within a value. They're used for permission flags, network subnet masks, hardware register manipulation, and performance-critical code paths. Understanding the binary representation of values is essential for predicting the output of operations like value & 0xFF (isolate lowest byte) or flags | (1 << 3) (set bit 3).
Our Hash Generator outputs hash values in hexadecimal — understanding hex is essential for working with SHA-256 outputs, checksums, and content-addressable storage systems.
Hexadecimal in memory and debugging
Every debugger, memory viewer, and disassembler works in hexadecimal. A 64-bit memory address like 0x7fff5fbff8a0 is 12 hex characters — representing 48 bits of address space. When you see a segmentation fault or access violation, the address in the error message is always hex. Core dumps and crash logs are written entirely in hex because it's the most compact human-readable binary representation.
Hex colour codes in web development
CSS colour codes like #FF5733 are simply three hex bytes: red (FF = 255), green (57 = 87), blue (33 = 51). The full 6-digit hex colour space covers all 16,777,216 possible RGB colours. Short codes like #F53 expand each digit to two identical digits: #FF5533. If you need to convert between hex colour codes and RGB or HSL, see our Color Converter.
Octal for Unix file permissions
Linux and macOS file permissions are three groups of three bits (owner / group / others), each encoding read (r=4), write (w=2), execute (x=1). Since three bits perfectly maps to one octal digit, permissions are expressed in octal. chmod 755 sets rwx (7) for owner, r-x (5) for group, r-x (5) for others. Understanding this octal-to-binary mapping makes Linux administration intuitive rather than rote memorisation.
Two's complement — how computers store negative numbers
Unsigned binary can only represent zero and positive numbers. To represent negative integers, virtually all modern processors use two's complement encoding. In two's complement, the most significant bit (MSB) is the sign bit: 0 for positive, 1 for negative. The value of the MSB is treated as a large negative number.
To negate a number in two's complement: invert all bits (flip 0→1 and 1→0), then add 1. This elegant trick means a single hardware adder handles both addition and subtraction without special cases. In an 8-bit signed integer, the range is −128 to +127. The value −1 is represented as 11111111 (all ones), and −128 as 10000000.
Two's complement explains some seemingly odd behaviour in integer arithmetic: in C, an int8_t holding 127 that overflows by adding 1 becomes −128, not 128. This is intentional and defined by the two's complement representation. Understanding this prevents subtle bugs in low-level code, especially when working with network protocols and binary file formats where specific byte patterns have precise numeric meanings. The Data Storage Converter is useful when thinking about how many bits or bytes are needed to represent values of a given magnitude.
FAQ
Common questions
What is a number base?
A number base (or radix) defines how many unique digits a positional number system uses. Decimal uses 10 digits (0–9), binary uses 2 (0–1), octal uses 8 (0–7), and hexadecimal uses 16 (0–9 plus A–F). The base determines the value of each digit position as a power of that base.
Why do computers use binary instead of decimal?
Electronic circuits have two stable states: on (high voltage) and off (low voltage). Binary maps directly to this physical reality — 1 for on, 0 for off. Using more than two states per circuit would require much more precise hardware and make error detection significantly harder. Binary is the simplest system that maps cleanly to transistor logic.
Why is hexadecimal so common in programming?
Each hexadecimal digit represents exactly 4 binary bits (a nibble), so two hex digits map perfectly to one byte. This makes hex a compact, human-readable shorthand for binary data. Memory addresses, colour codes, byte values, and hash outputs are all expressed in hex because it's far shorter than binary while remaining unambiguous.
How do I convert binary to decimal manually?
Write out each binary digit from right to left. Multiply each digit (0 or 1) by 2 raised to its position number (starting at 0 for the rightmost). Sum all the results. For example, binary 1011 = (1×8) + (0×4) + (1×2) + (1×1) = 8 + 0 + 2 + 1 = 11 in decimal.
What is two's complement and why does it matter?
Two's complement is the standard way computers represent negative integers in binary. To negate a number you flip all bits and add 1. The most significant bit acts as the sign bit — 0 for positive, 1 for negative. This representation allows a single set of addition circuits to handle both positive and negative numbers without special-casing.
When would I use octal in modern programming?
Octal is mostly encountered in Unix file permission notation. The chmod command uses octal digits where each digit represents three bits: read (4), write (2), execute (1). So chmod 755 means owner has rwx (7), group has r-x (5), and others have r-x (5). Outside of file permissions, octal is rarely used in modern code.
How many hexadecimal digits does it take to represent a 32-bit integer?
Exactly 8 hex digits. Each hex digit represents 4 bits, so 32 bits ÷ 4 bits per digit = 8 digits. A 64-bit integer requires 16 hex digits. This is why memory addresses on a 64-bit system are typically shown as 16 hex characters prefixed with 0x.
What is the difference between 0x prefix and # prefix for hex values?
0x is the standard prefix for hexadecimal literals in most programming languages (C, C++, JavaScript, Python, Go, Rust, Java). The # prefix is used specifically for CSS colour codes and HTML colour values. Both refer to hexadecimal numbers — the prefix is purely contextual convention, not a mathematical difference.
Can this converter handle floating-point numbers?
This tool converts integers between bases. Floating-point base conversion is considerably more complex because fractions in one base often produce repeating digits in another (just as 1/3 is a repeating decimal). For integer conversions — which cover the vast majority of programming use cases like addresses, flags, and byte values — this tool handles all common bases.
More in Value Converter