Skip to content
HNarzędzia
en
Categories

Number base converter - binary, octal, decimal, hexadecimal

Type a number and pick its base - the converter shows it in binary, octal, decimal, hexadecimal and any other base (2-36), including negative and fractional numbers, with two’s complement and the conversion steps.

  • Free
  • No sign-up
  • Private
  • Runs locally

You can use a minus sign, a decimal point (fractional part) and the 0x, 0b, 0o prefixes. Spaces and “_” are ignored.

Result - binary (BIN)
1111 1111

All bases

  • binary (BIN) · 2
    1111 1111
  • octal (OCT) · 8
    377
  • decimal (DEC) · 10
    255
  • hexadecimal (HEX) · 16
    FF

Two’s complement

This is how processors store signed integers: a negative number −x on n bits is 2ⁿ − x.

BitsTwo’s complement (binary)Two’s complement (hex)
8out of range-
160000 0000 1111 111100 FF
320000 0000 0000 0000 0000 0000 1111 111100 00 00 FF

Step-by-step conversion

Integer part: repeated division by 2
Dividend÷ 2QuotientRemainder
25521271
1272631
632311
312151
15271
7231
3211
1201

Reading the remainders from bottom to top gives: 11111111.

How to convert between number bases

  1. 1.

    Enter a number

    E.g. 255, -42, 0.625, FF, 0x1F or 0b1011. Spaces and underscores are ignored, so 1111_0000 works too.

  2. 2.

    Choose the source base

    Binary, octal, decimal, hexadecimal or “other” for any base from 2 to 36.

  3. 3.

    Choose the target base

    The result appears at the top; the number in all four common bases is listed below.

  4. 4.

    Check the steps

    See the repeated division, the positional expansion and the two’s complement form on 8, 16 and 32 bits.

Decimal to another base: repeated division

Divide by the target base with remainder until the quotient is 0, then read the remainders from bottom to top. For 11 in binary: 11 ÷ 2 = 5 r 1, 5 ÷ 2 = 2 r 1, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1, so 11₁₀ = 1011₂. Likewise 255₁₀ = 11111111₂ = 377₈ = FF₁₆.

For the fractional part multiply by the base instead and take the integer part of each product as the next digit: 0.625 × 2 = 1.25 → 1, 0.25 × 2 = 0.5 → 0, 0.5 × 2 = 1.0 → 1, so 0.625₁₀ = 0.101₂. The converter shows up to 24 fractional digits and marks a cut-off result with “…”.

Another base to decimal: positional expansion

Multiply each digit by the base raised to its position (counting from 0 at the right of the point) and add: 1011₂ = 1·2³ + 0·2² + 1·2¹ + 1·2⁰ = 8 + 0 + 2 + 1 = 11. Fractional digits use negative powers: A.8₁₆ = 10·16⁰ + 8·16⁻¹ = 10.5.

Bases above 10 use letters as digits: A = 10, B = 11 … Z = 35, so base 36 uses all of 0-9 and A-Z. Letter case does not matter. If you type a digit that does not exist in the chosen base (e.g. 2 in binary), the converter tells you which digits are allowed.

Quick reference table

DecimalBinaryOctalHex
81000108
10101012A
15111117F
161 00002010
100110 010014464
2551111 1111377FF
1024100 0000 00002000400

Shortcut: one hex digit is exactly 4 bits and one octal digit is 3 bits, so you can convert binary to hex by splitting into groups of four from the right (1010 1111 = AF). That is why the converter groups binary and hex digits by 4. Roman numerals are not a positional system - use the Roman numerals converter for those.

Two’s complement

Processors store signed integers in two’s complement: −x on n bits equals 2ⁿ − x. By hand: write |x| in binary, invert the bits and add 1: −5 → 00000101 → 11111010 → 11111011 (FB in hex). The ranges are −128…127 on 8 bits, −32,768…32,767 on 16 bits and about ±2.1 billion on 32 bits; outside them the tool shows “out of range”.

It also works backwards: enter a binary or hex pattern such as FF and the table shows what it means as a signed number (−1 on 8 bits, 255 on 16 bits). Two’s complement applies to integers only.

Frequently asked questions

How do I convert decimal to binary?

+
Divide by 2 with remainder until the quotient is 0 and read the remainders upwards. 11 → 1011.

What is FF in decimal?

+
FF₁₆ = 15 · 16 + 15 = 255. As an 8-bit signed value in two’s complement, FF is −1.

How do I convert hex to binary?

+
Replace each hex digit with its 4-bit binary form: 3F → 0011 1111 → 111111.

What do the letters in hexadecimal mean?

+
They are digits worth 10 to 15: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

How do I write a negative number in two’s complement?

+
Write the absolute value in binary, invert the bits and add 1. −5 on 8 bits is 11111011.

Why does 0.1 never end in binary?

+
A fraction has a finite binary expansion only if its denominator is a power of 2. 0.1 = 1/10, so it repeats forever: 0.000110011…₂.

Can I convert very large numbers?

+
Yes. Integers are handled with arbitrary precision (BigInt), so a 40-digit decimal number converts exactly.

Updated: