Number Base Converter

Convert whole numbers of any size between binary, octal, decimal, hexadecimal and any base from 2 to 36, with a place-value table.

Reviewed · How we build and check our calculators

Your details

A whole number of any size. Letters may be upper or lower case.

In hexadecimal (base 16)

FF

Binary
1111 1111
Octal
377
Decimal
255
Hexadecimal
FF
Bits needed
8 bits

Place values in decimal (base 10)

DigitPlace valueWorth
210^2 = 100200
510^1 = 1050
510^0 = 15

How the number base converter works

Convert whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36. Numbers of any length convert exactly, and a place-value table shows how the digits add up.

Formula

Value = Σ digit × base^position, counting positions from 0 at the right. To write a value in a new base, divide by the base again and again; the remainders, read from last to first, are the digits.

  1. 1

    Enter the number and its base

    The starting example is 255 in decimal.

  2. 2

    Divide by the new base

    255 ÷ 16 = 15 remainder 15, and 15 ÷ 16 = 0 remainder 15.

  3. 3

    Write the remainders as digits

    15 is the digit F in hexadecimal, so 255 = FF.

  4. 4

    Check the other bases

    The same value is 1111 1111 in binary (8 bits) and 377 in octal.

Worked example

The calculator opens with these values

Number
255
From
Decimal (base 10)
To
Hexadecimal (base 16)

In hexadecimal (base 16)

FF

Common numbers in binary, octal and hex

Powers of two are round numbers in binary and hex: 16 is 10 in hex and 128 is 1000 0000 in binary. In code, 0b marks binary, 0o octal and 0x hexadecimal; the converter accepts these prefixes when the matching base is chosen, so 0xFF reads as FF.

Common numbers in binary, octal and hexadecimal
DecimalBinaryOctalHexadecimal
1111
21022
410044
81000108
10101012A
15111117F
161 00002010
3210 00004020
64100 000010040
100110 010014464
1281000 000020080
2551111 1111377FF

How many values fit in 8, 16, 32 and 64 bits

n bits hold 2ⁿ different values. Unsigned, they run from 0 to 2ⁿ − 1. Signed (two's complement), the top bit carries the sign, so the range is split around zero. This is why a byte holds 0 to 255, and why a 32-bit counter stops at 4,294,967,295.

What a fixed number of bits can hold
BitsNameLargest unsigned valueIn hexSigned range
4Nibble15F−8 to 7
8Byte255FF−128 to 127
1616-bit65,535FFFF−32,768 to 32,767
3232-bit4,294,967,295FFFFFFFF−2,147,483,648 to 2,147,483,647
6464-bit18,446,744,073,709,551,615FFFFFFFFFFFFFFFF−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Reading hex color codes

Web colors are three bytes written in hex, #RRGGBB: one pair of digits each for red, green and blue, from 00 (none) to FF (255, full strength).

  • #FF0000 is pure red, #FFFFFF is white and #000000 is black.
  • #808080 is a mid gray: hex 80 is 128, about half of 255, on every channel.
  • The three-digit form doubles each digit, so #F80 is #FF8800, an orange.
  • An eight-digit code adds transparency as a fourth pair: #FF000080 is red at about 50% opacity.

Common questions

How do I convert binary to decimal?

Multiply each bit by its place value, 1, 2, 4, 8 and so on from the right, and add them. 1011 = 8 + 0 + 2 + 1 = 11. Choose From binary and To decimal to see each step in the place-value table.

Why do hexadecimal numbers use letters?

Base 16 needs sixteen digits, so after 0 to 9 it uses A = 10, B = 11, up to F = 15. One hex digit stands for exactly four bits, which is why colours and memory addresses are written in hex.

Can it convert very large numbers?

Yes. The converter works with whole numbers of any size up to 200 characters, beyond the 9,007,199,254,740,991 limit of ordinary JavaScript numbers, so 64-bit values such as FFFFFFFFFFFFFFFF convert exactly.

Add this calculator to your website

Free for blogs, schools and businesses. Paste this code into your page; the calculator works inside it, with no ads and no tracking. Please keep the credit line.