Binary / Hex Converter
Edit any format, decimal, binary, hex, or octal, the rest update instantly.
Number Bases Explained
- Decimal (base 10): the everyday number system, using digits 0-9.
- Binary (base 2): uses only 0 and 1, the fundamental language of digital computing, where each digit represents a power of 2.
- Hexadecimal (base 16): uses 0-9 and A-F, commonly used in programming for color codes, memory addresses, and compact binary representation (each hex digit maps to exactly 4 binary digits).
- Octal (base 8): uses digits 0-7, historically used in computing for representing binary data in a more compact form, still seen in Unix file permissions.
Keeping All Four Formats in Sync
This tool is deliberately built so that editing any single field, decimal, binary, hex, or octal, immediately recalculates the other three, rather than requiring you to pick a "from" and "to" base and run a one-way conversion. Internally, whatever value you type is parsed back into a plain numeric value first, then that value is re-rendered into all four base representations, which is why entering the same number's binary form in one field and its hex form in another will always agree, since both are ultimately derived from the same underlying number rather than converted independently from each other.
Worked Example
Starting from the default decimal value 255, the converter shows this as 11111111 in binary, since 255 equals 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1, every power of 2 from 2⁰ through 2⁷, which is exactly eight 1s. In hexadecimal, 255 converts to FF, since hex digit F represents 15, and 15 × 16 + 15 = 255. In octal, 255 converts to 377, since 3 × 64 + 7 × 8 + 7 × 1 = 192 + 56 + 7 = 255. For a second example, entering 202 as decimal shows 11001010 in binary (128 + 64 + 8 + 2 = 202) and CA in hexadecimal (12 × 16 + 10 = 202, where C represents 12 and A represents 10). Editing any one of the four fields instantly recalculates the other three, since all four are just different textual representations of the exact same underlying numeric value.
Common Mistakes When Converting Between Bases
A frequent manual error is forgetting that place values change with the base, treating a binary or hex number's digits as if they carried the same place values as decimal, which produces wildly incorrect results since binary place values double with each position while decimal place values multiply by ten. Another common mistake when converting hex to decimal by hand is misreading a letter digit's value, confusing which of A through F corresponds to which number 10 through 15, an easy slip since there's no visual cue linking a letter to its numeric value the way digit shapes are. A third mistake is dropping or adding leading zeros incorrectly when working with fixed-width binary or hex representations (like an 8-bit byte or a 4-digit hex color channel), which can silently produce a different number than intended if the width isn't preserved consistently.
How Positional Number Systems Work
Every number system covered here, decimal, binary, hex, and octal, is a positional system, meaning each digit's value depends on both the digit itself and its position, with each position representing a power of the base. In decimal, the digits of 255 represent 2×10² + 5×10¹ + 5×10⁰. In binary, each position represents a power of 2 instead of a power of 10, so the rightmost digit is worth 1 (2⁰), the next is worth 2 (2¹), then 4 (2²), and so on, doubling with each position moving left. Hexadecimal follows the same logic with powers of 16, and octal with powers of 8. Understanding this shared positional structure is what makes it possible to convert between any of these bases using the same fundamental approach, decompose the number into place values for the source base, then reconstruct it using place values for the target base, exactly what this calculator automates.
Why Different Bases Matter in Computing
Each base serves a distinct practical purpose in programming and computer science rather than being arbitrary alternatives to decimal. Binary directly reflects how data is physically stored and processed at the hardware level, every bit in memory is either 0 or 1. Hexadecimal is used constantly as a compact, human-readable stand-in for binary, since converting between them is a simple digit substitution (each hex digit maps to exactly 4 bits) rather than requiring arithmetic, which is why memory addresses, color codes (like #FF5733), and low-level debugging output are almost always shown in hex rather than raw binary. Octal was historically significant in early computing systems that used 6-bit or 12-bit word sizes evenly divisible by 3 (the number of bits per octal digit), and persists today mainly in specific legacy contexts like Unix file permission notation (such as chmod 755).
Common Uses for Each Base in Practice
Web developers encounter hexadecimal constantly through CSS color codes, where a color like #FF5733 encodes red, green, and blue intensity values, each ranging from 00 to FF (0 to 255 in decimal), packed into a compact six-character hex string. Hardware and embedded systems programmers work directly with binary when configuring registers, flags, and bitwise operations, since each bit often controls a specific hardware feature independently. Network engineers use hexadecimal for representing MAC addresses and IPv6 addresses, both of which are naturally expressed as sequences of hex digits. System administrators managing Unix and Linux permissions still encounter octal directly, since the classic chmod command uses three-digit octal numbers (like 755 or 644) to represent read, write, and execute permissions for owner, group, and others, with each digit's three bits corresponding to those three permission types.
Reading Binary and Hex at a Glance
With practice, recognizing common binary and hex patterns becomes faster than mentally converting every number from scratch. Powers of two in binary have a distinctive single-1 pattern, 1 is 1, 2 is 10, 4 is 100, 8 is 1000, and so on, with the 1 shifting one position left each time the value doubles. In hex, the sequence just below a round power of 16 is often recognizable, FF (255) is one less than 100 in hex (256), similar to how 99 is one less than 100 in decimal. Byte values (8-bit numbers, ranging 0-255 in decimal) always convert to exactly two hex digits, which is part of why hex is so convenient for representing byte-oriented data like colors, memory addresses, and file contents, each byte maps cleanly to a fixed two-character hex representation with no ambiguity about digit boundaries.
Frequently Asked Questions
Why does hex use letters A-F?
Hexadecimal needs 16 distinct digits (0 through 15), but our number system only has 10 digit symbols, so A through F represent the values 10 through 15.
Does this support negative numbers?
This converter works with non-negative whole numbers. Negative number representation in binary (like two's complement) depends on a fixed bit-width, which varies by context, so it's outside the scope of this simple converter.
Why does each hex digit correspond to exactly 4 binary digits?
Hexadecimal is base 16, and 16 is exactly 2 to the power of 4, so every possible 4-bit binary combination (0000 through 1111) maps to exactly one hex digit (0 through F) with no overlap or gaps. This clean mathematical relationship is why hexadecimal is so commonly used to represent binary data compactly, converting between the two is a simple digit-by-digit substitution rather than requiring full arithmetic.
How do you manually convert a decimal number to binary?
The standard manual method is repeated division by 2, dividing the decimal number by 2, recording the remainder (0 or 1), then repeating with the quotient until it reaches 0. Reading the remainders from last to first gives the binary representation. This calculator performs the equivalent conversion instantly using built-in number base conversion rather than manual repeated division.
Why do computers use binary instead of decimal internally?
Computer hardware is built from transistors and circuits that are most reliably designed around two distinct states, on and off, or high and low voltage, which map naturally onto the two digits of binary (0 and 1). Building reliable hardware that distinguishes ten different voltage levels for decimal digits would be far more complex and error-prone than distinguishing just two states, which is why binary became the foundational number system for digital computing.
What happens if I enter an invalid character for the selected base?
The calculator validates each field against the characters valid for that specific base as you type, decimal only accepts 0-9, binary only accepts 0 and 1, hex accepts 0-9 and A-F, and octal accepts 0-7. If you type a character outside that field's valid range, an error message appears explaining which characters are allowed, and the other fields won't update until valid input is entered.