Skip to content
Calc.

Number Base Converter (Binary, Octal, Decimal, Hex)

Convert a whole number between binary, octal, decimal, hexadecimal or any base from 2 to 36, with exact results for numbers of any length. The method below shows the repeated-division and positional-value steps so you can check the answer by hand.

Last updated: October 2026

Binary (base 2)

11111111

Formula below · 2 sources (mathsisfun.com, mathworld.wolfram.com) · Updated Oct 2026

Compare with similar

About this calculator

A positional numeral system writes a number as digits times powers of a base. In base b the digit string dₙ … d₂ d₁ d₀ means dₙ×bⁿ + … + d₂×b² + d₁×b + d₀. Decimal uses b = 10 and the digits 0-9; binary uses b = 2 and the digits 0 and 1; octal b = 8 (0-7); hexadecimal b = 16, with the letters A-F standing for 10-15. Bases above 10 continue through the alphabet, so base 36 uses 0-9 and A-Z.

The converter works in two steps. First it reads the input in the source base, multiplying the running total by the base and adding each digit from left to right (Horner's method): for 1F4 in hex that is ((1×16 + 15)×16) + 4 = 500. Then it writes that value in the target base by repeated division: divide by the base, keep the remainder as the next digit (from right to left), and continue with the quotient until it reaches 0. For 500 to octal: 500 ÷ 8 = 62 remainder 4; 62 ÷ 8 = 7 remainder 6; 7 ÷ 8 = 0 remainder 7, so 500 = 764₈.

Between binary, octal and hexadecimal there is a shortcut because 8 = 2³ and 16 = 2⁴: group the bits in threes (octal) or fours (hex) from the right and translate each group on its own. 1111 1010₂ is F A in hex and 011 111 010₂ is 372 in octal, with no arithmetic needed.

The arithmetic is done with arbitrary-precision integers, so a 64-bit, 128-bit or longer value converts exactly instead of being rounded past 2⁵³ as ordinary floating-point numbers are. Whole numbers only: a leading minus sign is kept, prefixes 0x, 0b and 0o are accepted when they match the chosen source base, and spaces or underscores used as digit separators are ignored.

How to use

Example (the defaults): 255 from decimal to binary. 255 ÷ 2 = 127 r 1; 127 ÷ 2 = 63 r 1; 63 ÷ 2 = 31 r 1; 31 ÷ 2 = 15 r 1; 15 ÷ 2 = 7 r 1; 7 ÷ 2 = 3 r 1; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1. Reading the remainders from last to first gives 11111111, the largest 8-bit value. Hex to decimal: choose From base = Hexadecimal and To base = Decimal, enter 1F4. 1×256 + 15×16 + 4 = 500. Binary to hex: enter 10101101 with From base = Binary and To base = Hexadecimal. Grouping in fours, 1010 = A and 1101 = D, so the result is AD. Decimal to base 36: 1,000,000 becomes LFLS, because 1,000,000 = 21×36³ + 15×36² + 21×36 + 28 and the digits 21, 15, 21, 28 are L, F, L, S.

Frequently asked questions

How do I convert decimal to binary by hand?

Divide the number by 2 and write down the remainder (0 or 1). Divide the quotient by 2 again, and keep going until the quotient is 0. The remainders, read from the last one back to the first, are the binary digits. For 37: 37 ÷ 2 = 18 r 1, 18 ÷ 2 = 9 r 0, 9 ÷ 2 = 4 r 1, 4 ÷ 2 = 2 r 0, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1, so 37 = 100101₂. Check it the other way: 32 + 4 + 1 = 37.

How do I convert hexadecimal to decimal?

Give each hex digit its value (A = 10, B = 11, C = 12, D = 13, E = 14, F = 15), multiply by the matching power of 16 and add. The rightmost digit is times 1, the next times 16, then 256, 4096 and so on. 2AF = 2×256 + 10×16 + 15 = 512 + 160 + 15 = 687. The converter does the same thing left to right with Horner’s method, which avoids computing the powers separately.

Why do programmers use hexadecimal and octal?

Both are compact ways of writing binary. One hex digit stands for exactly four bits and one octal digit for exactly three, so a 32-bit value is 8 hex digits instead of 32 bits, and the translation in either direction is digit by digit with no arithmetic. Hex is used for memory addresses, colour codes (#FF8800), byte dumps and bit masks; octal survives mainly in Unix file permissions, where 755 encodes three groups of three permission bits.

Can it convert negative numbers and fractions?

A leading minus sign is kept and the magnitude is converted, so -10 in decimal is -1010 in binary. That is the signed-magnitude form, not the two’s complement form that CPUs use; for an 8-bit or 32-bit two’s complement pattern use the two’s complement calculator. Fractions are not supported: a value such as 0.1 has no finite binary expansion, so a fractional converter must pick a precision, which is a different tool.

What is the largest number it can handle?

There is no practical limit. The conversion uses arbitrary-precision integers (BigInt), so a 256-bit hash, a 128-bit UUID written in hex or a decimal number with hundreds of digits converts exactly. Ordinary JavaScript numbers would lose precision above 2⁵³ (about 9 × 10¹⁵), which is why some online converters return wrong trailing digits for 64-bit values.

Which letters are valid in base 36?

Base 36 uses the ten digits 0-9 followed by the 26 letters A-Z, so A = 10, B = 11, up to Z = 35. Letters are case-insensitive here. The same rule covers every base from 11 to 36: base 12 uses 0-9, A and B, and base 20 uses 0-9 and A-J. If you enter a digit that is too large for the chosen source base (for example 8 in octal, or G in hex), the converter says which digit is invalid instead of guessing.

Related calculators

Sources & references

Think a result is wrong? Report a problem with this calculator.