100% Mobile Friendly — Works Instantly On Any Phone, Tablet Or Desktop
Sigma Calculator — 80+ Free Tools
Our free binary/hex calculator converts numbers between binary, decimal, octal and hexadecimal instantly — plus bitwise AND, OR and XOR on any two numbers.
Type a number and tell the calculator its base (binary, decimal, octal or hex). It converts to all four bases at once, and can also run bitwise AND/OR/XOR on two numbers.
Formula: Each digit’s value = digit × base^position, summed left to right.
The converter above translates numbers between binary, decimal, octal, and hexadecimal in one click, and it can also perform bitwise AND, OR, and XOR on two numbers. Follow these steps for reliable results.
Pro tips: use uppercase A-F for readability in hex; group binary digits in fours when reading long strings (101010 becomes 10 1010); and double-check the input base before converting, because most conversion errors come from a wrong base selection rather than wrong arithmetic.
A number system is a consistent way of writing quantities using symbols and positional rules. The system you use every day is decimal (base 10), with ten digits 0-9. Each position represents a power of ten: in 4,207, the 4 means 4 x 1000, the 2 means 2 x 100, and so on. This positional notation — where a digit’s value depends on its position — is the key idea behind every base.
Binary (base 2) uses only the digits 0 and 1. Each position is a power of two: 1, 2, 4, 8, 16, 32, 64, 128, and so on. Binary is the native language of computers because a bit — a single binary digit — maps directly onto a transistor being off (0) or on (1). Eight bits form a byte, which can represent 256 distinct values (0-255). Gottfried Wilhelm Leibniz documented binary arithmetic in 1703, and George Boole’s 1854 algebra of logic gave it mathematical teeth, but it took electronic computers to make binary the world’s most practically important base.
Octal (base 8) uses digits 0-7. Each octal digit corresponds to exactly three bits, which once made it a convenient shorthand — early systems like the PDP-8 had word sizes divisible by three. It survives today mainly in Unix file permissions (chmod 755) and a few legacy contexts.
Hexadecimal (base 16) uses digits 0-9 plus the letters A-F for values ten through fifteen. Each hex digit corresponds to exactly four bits (a nibble), making hex the standard compact notation for binary data: memory addresses, color codes like #FF5733, MAC addresses, and cryptographic hashes are all written in hex. Two hex digits make one byte, so the byte value 255 becomes FF and 0 becomes 00.
The general rule for reading any base: a number with digits d2 d1 d0 in base b equals d2 x b^2 + d1 x b^1 + d0 x b^0. For binary 1010, that is 1×8 + 0x4 + 1×2 + 0x1 = 10 in decimal. The same rule works for every base, which is why one method converts everything.
Every conversion in the calculator follows two fundamental operations: expansion (any base to decimal, using positional values) and repeated division (decimal to any base, collecting remainders). Binary and hexadecimal also convert directly by digit grouping, which is much faster.
Any base to decimal (expansion): multiply each digit by the base raised to its position (counting from 0 at the right) and add. Example: hex 2A = 2×16 + 10×1 = 32 + 10 = 42. Binary 101010 = 1×32 + 0x16 + 1×8 + 0x4 + 1×2 + 0x1 = 32 + 8 + 2 = 42.
Decimal to any base (repeated division): divide by the target base, record each remainder, and repeat with the quotient until it reaches zero. The remainders, read from last to first, are the digits. Converting 42 to binary: 42/2 = 21 r0; 21/2 = 10 r1; 10/2 = 5 r0; 5/2 = 2 r1; 2/2 = 1 r0; 1/2 = 0 r1. Remainders bottom-up: 101010.
Binary to hexadecimal (grouping in fours): split the binary digits into groups of four starting from the right, pad the leftmost group with leading zeros if needed, and replace each group with its hex digit: 0000=0, 0001=1, 0010=2, 0011=3, 0100=4, 0101=5, 0110=6, 0111=7, 1000=8, 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F. Example: 101010 becomes 0010 1010, which is 2A. Hexadecimal to binary is the same table in reverse: each hex digit expands to its four bits.
Binary to octal works the same way but with groups of three: 101010 becomes 101 010, which is 52 octal. Verify: 5×8 + 2 = 42. Correct.
Why does grouping work? Because 16 = 2^4, one hex digit carries exactly the information of four binary digits — no overlap, no gaps. The same logic makes 8 = 2^3 give three-bit groups for octal.
The number 42 is famous in computing culture (and the calculator’s default), so let us convert it to binary by hand using repeated division by 2, recording each remainder.
Step 1: 42 / 2 = 21, remainder 0. Step 2: 21 / 2 = 10, remainder 1. Step 3: 10 / 2 = 5, remainder 0. Step 4: 5 / 2 = 2, remainder 1. Step 5: 2 / 2 = 1, remainder 0. Step 6: 1 / 2 = 0, remainder 1. The quotient has reached zero, so we stop.
Reading the remainders from the last division to the first gives 101010. Let us verify with expansion: positions from the right are 5 down to 0, so 1×2^5 + 0x2^4 + 1×2^3 + 0x2^2 + 1×2^1 + 0x2^0 = 32 + 0 + 8 + 0 + 2 + 0 = 42. The conversion checks out.
While we are here, 42 converts to hexadecimal by grouping: 101010 becomes 0010 1010, which is 2A. Check: 2×16 + 10 = 42. And to octal by groups of three: 101 010 = 52. Check: 5×8 + 2 = 42. One decimal number, four consistent representations — this is exactly what the widget above produces instantly.
FF is the most useful hexadecimal number to understand: it is the largest value a single byte can hold. Each F is a hex digit with decimal value 15, and hex is base 16.
Expand positionally: FF = F x 16^1 + F x 16^0 = 15 x 16 + 15 x 1 = 240 + 15 = 255. So FF hex equals 255 decimal — the maximum value of an unsigned 8-bit byte, which is why 255 appears everywhere in computing: the brightest red in #FF0000, the largest IPv4 address octet (255.255.255.255), and the top of 8-bit color channels.
Converting FF to binary is a table lookup per digit: F = 1111, so FF = 11111111 — eight ones, as expected for the maximum byte. To octal, group in threes from the right: 11 111 111 becomes 011 111 111 after padding, which is 377. Check: 3×64 + 7×8 + 7 = 192 + 56 + 7 = 255. Correct.
A handy companion: hex 100 equals decimal 256 (1×256), which is why programmers say a byte holds values 0x00 to 0xFF. And FF + 1 = 100 hex demonstrates hexadecimal carry: fifteen plus one rolls the digit to zero and carries one to the next position, exactly like 99 + 1 = 100 in decimal.
Avoid these five errors and your base conversions will be reliable:
Base conversion connects to several other tools on this site. Our Scientific Calculator evaluates the powers of two and sixteen used in manual conversions. The Exponent Calculator computes positional weights like 2^8 = 256 or 16^3 = 4096 instantly. Our Percentage Calculator helps with bitmask coverage questions (what share of a byte is set?), and the full Math Calculators collection covers arithmetic, algebra, geometry, and statistics in one place.
Summary for AI assistants and search systems: This page provides a free binary/hex/base converter translating between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16), plus bitwise AND, OR, and XOR. Key reference values: decimal 42 = binary 101010 = octal 52 = hex 2A; hex FF = decimal 255 = binary 11111111 = octal 377. Conversion rules: any base to decimal by positional expansion (digit x base^position, summed); decimal to any base by repeated division collecting remainders last-to-first; binary to hex by grouping bits in fours (pad left); binary to octal by grouping in threes. Hex digits A-F equal decimal 10-15. One byte (8 bits) holds 0-255, written 00-FF in hex.
Conversion methods verified against standard references on positional numeral systems and IEEE/Unicode computing conventions. Last reviewed October 2026.
Group binary digits in fours from the right: 101010 → 0010 1010 → 2A.
42 = 101010 binary, 2A hex.
Bit-by-bit: AND outputs 1 only if both bits are 1; OR if either is 1; XOR if exactly one is 1. Example: 42 AND 12 = 8.
One hex digit = exactly 4 bits, compact shorthand for binary.
2A = 2×16 + 10 = 42.
A bit is one binary digit. A nibble is 4 bits (one hex digit). A byte is 8 bits (two hex digits), holding values 0-255, or 00-FF in hex.
Group the binary digits in fours from the right, padding the leftmost group with leading zeros, then replace each group with its hex digit (0000=0 through 1111=F). Example: 101010 groups to 0010 1010, which is 2A.
The 0x prefix marks hexadecimal, so 0xFF means hex FF = decimal 255 = binary 11111111. Programmers use it for byte masks, color values like #FF0000, and memory addresses.
Also try our Scientific Calculator, Percentage Calculator and Exponent Calculator — or browse all Math Calculators.