Binary Converter - Decimal, Hex, Octal
Enter a number in any base and instantly see its equivalent in all four numeral systems: binary (base 2), decimal (base 10), hexadecimal (base 16), and octal (base 8). Choose your input base, pick signed or unsigned mode and a bit width, and the step-by-step panel shows exactly how each conversion is done.
How number bases work
Every number base represents quantity using a fixed set of digits and a positional weighting system. Decimal (base 10) uses digits 0-9, and each position is worth ten times the one to its right. Binary (base 2) uses only 0 and 1, and each position is worth twice the one to its right. That is why 1011 in binary equals 1x8 + 0x4 + 1x2 + 1x1 = 11 in decimal. Hexadecimal (base 16) extends the digit set to 0-9 and A-F, where A=10 and F=15, making it a compact shorthand for binary: one hex digit represents exactly four binary digits (a nibble). Octal (base 8) uses digits 0-7, and one octal digit represents exactly three binary digits, which is why it appears in Unix file permissions like chmod 755.
How to convert between bases
To convert decimal to binary, divide the number by 2 repeatedly and collect the remainders from bottom to top. For example, 42 divided by 2 gives 21 remainder 0, then 10 remainder 1, then 5 remainder 0, then 2 remainder 1, then 1 remainder 0, then 0 remainder 1 - reading the remainders upward gives 101010. To convert binary to hexadecimal, split the binary string into 4-bit groups from the right and replace each group with its hex digit: 1010 becomes A and 0010 becomes 2, so 00101010 becomes 0x2A. For octal, split into 3-bit groups instead: 101 010 becomes 5 2, so octal 52. These rules work in both directions, and the step-by-step panel in this calculator shows every stage.
Signed vs unsigned integers and two's complement
An unsigned 8-bit integer stores values from 0 to 255 using all 8 bits for magnitude. A signed 8-bit integer can represent -128 to +127 by reserving the most significant bit (bit 7) as a sign indicator, but most computers use two's complement rather than a simple sign bit. In two's complement, a negative number is formed by inverting all bits of the positive version and adding 1. So -1 in 8-bit two's complement is 11111111 (0xFF), and -128 is 10000000 (0x80). Two's complement has the elegant property that ordinary binary addition works correctly for both positive and negative numbers without special hardware. This calculator shows the two's complement bit pattern when you select signed mode.
Where you use these bases in practice
Binary is the native language of digital logic: every bit in memory, every CPU register, and every network packet is ultimately a string of 0s and 1s. Hexadecimal is used everywhere binary needs to be shown concisely: RGB web colors (#FF5733), memory addresses (0x7fff5fbff8c0), and machine code listings. Octal survives mainly in Unix/Linux file permissions, where each of the three permission groups (owner, group, others) maps to a 3-bit pattern: rwx = 111 = 7, rw- = 110 = 6, r-- = 100 = 4. Knowing how to read and convert between these bases is a core skill for programmers, network engineers, and electronics engineers.
Common number conversions - binary, decimal, hex, octal
| Decimal | Binary | Hex | Octal | Notes |
|---|---|---|---|---|
| 0 | 0000 | 0 | 0 | Zero |
| 1 | 0001 | 1 | 1 | Least significant bit |
| 2 | 0010 | 2 | 2 | 2^1 |
| 4 | 0100 | 4 | 4 | 2^2 |
| 8 | 1000 | 8 | 10 | 2^3 |
| 10 | 0000 1010 | A | 12 | Decimal 10 |
| 15 | 0000 1111 | F | 17 | Max nibble |
| 16 | 0001 0000 | 10 | 20 | 2^4 |
| 32 | 0010 0000 | 20 | 40 | 2^5 |
| 64 | 0100 0000 | 40 | 100 | 2^6 |
| 127 | 0111 1111 | 7F | 177 | Max signed 8-bit |
| 128 | 1000 0000 | 80 | 200 | 2^7 |
| 255 | 1111 1111 | FF | 377 | Max unsigned 8-bit, 0xFF |
| 256 | 0001 0000 0000 | 100 | 400 | 2^8 |
| 1024 | 0000 0100 0000 0000 | 400 | 2000 | 2^10, one kibibit |
Quick reference for frequently used values in programming and electronics.
Frequently asked questions
How do I convert binary to decimal?
Multiply each binary digit by its positional power of 2, then add the results. Starting from the rightmost digit (position 0): 1x2^0 = 1, 1x2^1 = 2, 0x2^2 = 0, 1x2^3 = 8. So binary 1011 = 8 + 0 + 2 + 1 = 11 in decimal. This calculator shows the full breakdown in the step-by-step panel.
How do I convert decimal to binary?
Divide the decimal number by 2 repeatedly, recording the remainder each time. When the quotient reaches 0, read the remainders from bottom to top. For example, 13: 13/2=6 r1, 6/2=3 r0, 3/2=1 r1, 1/2=0 r1 - reading up gives 1101. Enter 13 in this converter and select "Show steps" to see this worked out.
What is the difference between signed and unsigned binary?
Unsigned binary treats all bits as magnitude, so an 8-bit unsigned integer holds 0 to 255. Signed binary (using two's complement) reserves the most significant bit as a sign indicator, giving a range of -128 to +127 for 8 bits. The bit pattern for -1 in 8-bit two's complement is 11111111, the same as 255 unsigned, which is why the sign mode matters when interpreting binary.
Why is hexadecimal used in computing?
Each hex digit represents exactly 4 binary digits (a nibble), so a 32-bit value that would take 32 binary characters to write needs only 8 hex digits. This makes hex a compact, human-readable shorthand for binary. It appears in HTML/CSS color codes, memory addresses, error codes, and IP/MAC addresses for this reason.
What does 0xFF mean?
0x is the conventional prefix for hexadecimal numbers. FF in hex is 15x16 + 15 = 255 in decimal, or 11111111 in binary. It is the maximum value of an unsigned 8-bit byte and appears frequently in color codes (full red = 0xFF0000), bit masks, and initialization patterns.
What is the Hamming weight or popcount?
The Hamming weight (also called popcount or population count) is the number of 1-bits in a binary representation. For 42 (binary 00101010), the Hamming weight is 3 because there are three 1s. It is used in error detection, cryptography, and as a fast CPU instruction (POPCNT) in modern processors.