Number Base Converter
Convert a number between any bases from 2 to 36, with its binary, octal, decimal and hexadecimal forms side by side and a step-by-step division table. Fractions and very long numbers work too.
- Octal (8)377
- Decimal (10)255
- Hexadecimal (16)FF
- Bits in the whole part8
- Digits in base 28
Repeated division by 2 (whole part)
How it is calculated
Computers store data in binary (0 and 1); hexadecimal writes every 4 binary digits as one digit. That is why CSS colour codes are hex: #1A2B3C means red 1A = 26, green 2B = 43, blue 3C = 60 (CSS Color 4, §5.2). Octal shows up in Unix/POSIX file permissions: chmod 755 gives the owner read, write and execute (7 = 4 + 2 + 1) and the group and others read and execute (5 = 4 + 1). Every base from 2 to 36 is written with the digits 0–9 and the letters A–Z; JavaScript’s Number.prototype.toString(radix) uses the same 36 characters (ECMA-262 §6.1.6.1.20).
To base 10: Σ dₖ × bᵏ · From base 10: divide by b repeatedly and read the remainders backwardsb: the base · dₖ: the digit in position k from the right (k starts at 0). Bases above 10 use A = 10, B = 11, … Z = 35.- The number is turned into its value by multiplying each digit by a power of the base and adding up.
- That value is divided by the target base again and again; the remainders read bottom-up are the digits in the target base.
- A fraction is multiplied by the target base again and again; the whole part of each product is a digit. Fractions that never end are cut at 32 digits.
- Everything uses exact integer arithmetic, so long numbers are not rounded.
Example
255 to binary: 255 ÷ 2 = 127 remainder 1, 127 ÷ 2 = 63 remainder 1, … 1 ÷ 2 = 0 remainder 1; read backwards, 11111111₂. The same number is 377₈ in octal and FF₁₆ in hex. 42 = 101010₂ = 52₈ = 2A₁₆. A fraction: 0.625 × 2 = 1.25 → 1; 0.25 × 2 = 0.5 → 0; 0.5 × 2 = 1 → 1, so 0.625 = 0.101₂.
Frequently asked questions
What is the quick way from binary to hex?
Split the binary number into groups of 4 from the right and turn each group into one hex digit: 1101 1110₂ = DE₁₆. For octal use groups of 3: 101 010₂ = 52₈.
Why can’t 0.1 be written exactly in binary?
A fraction ends in a base only if its denominator has no prime factors other than the base’s. 0.1 = 1/10 and 10 = 2 × 5; 5 is not a factor of 2, so 0.1 = 0.000110011…₂ goes on for ever. Most programming languages store decimals in the IEEE 754 binary64 format, with 53 binary digits (for JavaScript, ECMA-262 §6.1.6.1), so 0.1 is rounded and 0.1 + 0.2 is not exactly 0.3.
How are negative numbers converted?
The tool keeps the sign: −10 = −1010₂. The two’s complement form computers use depends on the word size: in n bits a negative number is stored as its remainder modulo 2ⁿ, so in 8 bits −10 → 256 − 10 = 246 = 11110110₂ (JavaScript’s ToUint8 conversion also turns −10 into 246, ECMA-262 §7.1.11).
Source
- ECMA-262 (ECMAScript 2025) §6.1.6.1.20 Number::toString(x, radix): bases 2–36 and the digits 0–9, a–z; §19.2.5 parseInt
- ECMA-262 §6.1.6.1: the Number type is IEEE 754-2019 binary64
- ECMA-262 §7.1.11 ToUint8: the integer modulo 2⁸
- IEEE 754-2019 Standard for Floating-Point Arithmetic (binary64)
- W3C CSS Color Module Level 4, §5.2 The RGB hexadecimal notations (#RRGGBB)
- POSIX.1-2024 (IEEE Std 1003.1), chmod: octal mode bits (0400 … 0001)