ToolsWhisper
Developer tools

Number Base Converter

Convert integers between binary, octal, decimal, hex and any base to 36.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
Result
  • Binary0b1111 1111
  • Octal0o377
  • Decimal255
  • Hexadecimal0xFF
  • Base 327v
  • Base 3673
  • Base 7513

Needs 8 bits.

Two's complement
WidthBinaryHex
16-bit00000000 111111110x00FF
32-bit00000000 00000000 00000000 111111110x000000FF
64-bit00000000 00000000 00000000 00000000 00000000 00000000 00000000 111111110x00000000000000FF

About this tool

Type a number in any base from 2 to 36 and see it in binary, octal, decimal, hexadecimal and more at once. Values are held as arbitrary-precision integers, so a forty-digit hex string converts without losing a digit.

How to use it

  1. Type or paste the number. The 0x, 0b and 0o prefixes are accepted, and so are spaces, commas and underscores between digits.
  2. Choose the base it is written in.
  3. Copy any of the results. A negative number also shows its two's-complement pattern at each width it fits.

Prefixes, separators and case

The conventional prefixes are recognised for the base you choose: 0x for hexadecimal, 0b for binary and 0o for octal. A leading minus sign makes the number negative.

Spaces, commas and underscores are ignored, so 1111_0000, 1111 0000 and 11110000 are the same number. Letters are not case-sensitive. Bases above 10 use the letters of the alphabet for the extra digits, which is why base 16 stops at f and base 36 stops at z.

Why exactness matters

JavaScript numbers are 64-bit floating-point values, and they hold whole numbers exactly only up to 9,007,199,254,740,991. Above that, a converter built on ordinary numbers rounds without telling you:

Input A floating-point converter shows The exact value
0xFFFFFFFFFFFFFFFF 18446744073709552000 18446744073709551615
0x7FFFFFFFFFFFFFFF 9223372036854776000 9223372036854775807

Those are the largest unsigned and signed 64-bit integers, which is exactly where hashes, identifiers and bit masks tend to live. This tool does its arithmetic on big integers, so every digit is right at any size.

Negative numbers and two's complement

Computers store negative integers in two's complement: invert every bit of the positive value and add one. The same bit pattern is a different number depending on how wide the integer is.

  • -1 is 11111111 (0xFF) in 8 bits, 0xFFFF in 16 bits and 0xFFFFFFFF in 32 bits.
  • -128 is 10000000 in 8 bits, the lowest value an 8-bit signed integer holds.

The table shows the pattern at every standard width that can hold the value. A width is left out when the number does not fit it, because 128 is simply not a signed 8-bit value.

Conversions worth knowing by heart

  • One hex digit is exactly four bits, so a byte is always two hex digits. That is why hex is used to write binary data.
  • One octal digit is exactly three bits, which is why Unix permissions are written in octal. See the chmod calculator.
  • 0xFF is 255, 0x7FFFFFFF is 2,147,483,647 (the largest signed 32-bit integer) and 0xFFFFFFFF is 4,294,967,295.
  • A Unix timestamp of 2,147,483,647 is the last second a signed 32-bit clock can count.

Frequently asked questions

Is there a limit on the size of the number?

No fixed limit. Numbers of hundreds of digits convert instantly; only extremely long inputs take noticeably longer.

Does it convert fractions such as 0.1 or 3.14?

No, integers only. Fractional values have no exact binary form in general, which is a separate problem from changing the base of a whole number.

Why do binary results appear in groups of four?

Four binary digits make one hex digit, so grouping by four makes it easy to read a binary number against its hex form. The copy button gives the digits without the spaces.

Can I convert a colour such as #ff8800?

You can convert each pair of hex digits here, but the colour converter does the whole job, including RGB, HSL and CSS formats.

Related tools