Number Base Converter

Whole numbers of any size, converted between decimal, hexadecimal, binary, octal and any base up to 36, with their bytes and the way their bits read at 8, 16, 32 and 64 bits.

Overview

A base is how many digits a way of writing numbers uses. The number stays the same, only its digits change: 255 in decimal is FF in hexadecimal and 11111111 in binary. Hexadecimal is the usual shorthand for binary because each of its digits is exactly four bits, so a byte is two digits and a memory dump, a MAC address or an error code reads as pairs. The converter does that rewriting, exactly and at any length, and shows what the same bits mean to a program that reads them as a fixed-width integer.

Web interface

There are five fields: decimal, hexadecimal, binary, octal and one whose base you choose from 2 to 36, which starts at 36. Typing into any of them rewrites the others as you type. A complaint about the input appears under its field once you stop typing, and the buttons under the fields fill in an example.

Under the fields, Details lists the number of bits, the number grouped for reading, its bytes and its Unicode character, and Fixed widths the 8, 16, 32 and 64-bit readings of its bits. A click on a value selects all of it, ready to copy.

PatternExample
/convert/number-base/{decimal}/convert/number-base/255
/convert/number-base/0x{hex}/convert/number-base/0x80070005
/convert/number-base/0b{binary}/convert/number-base/0b10101010
/convert/number-base/0o{octal}/convert/number-base/0o755
/convert/number-base/{digits}/{base}/convert/number-base/zz/36

A minus sign goes in front, /convert/number-base/-1. The address bar follows the field you type in, in the same forms; a number longer than 200 digits is left out of it.

Input rules

  • Each field takes the digits of its base, in upper or lower case, with a minus or plus sign in front.
  • The hexadecimal field accepts 0x, binary 0b and octal 0o in front of the digits.
  • Spaces, underscores and apostrophes between digits are ignored, and in decimal a comma may group thousands, 1,000,000.
  • A leading zero is only a zero. C reads 0755 as octal, 493; here the decimal field reads it as 755.
  • Up to 2,000 digits are converted, exactly.
MessageWhen
"G" is not a hexadecimal digit. Hexadecimal uses 0 to 9 and A to F.a digit the base does not have; binary, octal and decimal say the same in their terms
"Z" is not a digit in base 20, which uses 0 to 9 and A to J.the same for a chosen base
Only whole numbers are converted.a point, or a comma that does not group thousands
There are no digits after the 0x.a prefix on its own
That is more than 2,000 digits, more than the page converts.a longer number

Reading the details

RowWhat it is
Bitshow many binary digits the number takes, and how many of them are 1
Decimal, Hexadecimal, Binary, groupedthe number in groups of three or four digits from the right, for reading; the fields above stay ungrouped, for copying
Bytes, big-endianthe fewest bytes that hold the number, the most significant first, as network protocols send them
Bytes, little-endianthe same bytes the other way round, as x86 and ARM processors keep them in memory
Unicodethe code point the number names, up to U+10FFFF, and its character; control characters are named as such

For 0x80070005 the bytes are 80 07 00 05 big-endian and 05 00 07 80 little-endian. A negative number's bytes are its two's complement at the smallest whole number of bytes, so -1 is FF.

Fixed widths

A program stores an integer in a fixed number of bits, and whether it reads those bits as signed or unsigned changes the number. Fixed widths shows each of 8, 16, 32 and 64 bits that can hold the number, the bits in hexadecimal, and both readings. A signed reading uses two's complement: the top bit counts as minus 2 to the power of the width less one.

WidthBits in hexUnsignedSigned
32-bit0x800700052147942405-2147024891
8-bit0xFF255-1
16-bit0xFFFF65535-1
64-bit0xFFFFFFFFFFFFFFFF18446744073709551615-1

The first row is why a Windows error code shows up both as 0x80070005 and as -2147024891: it is E_ACCESSDENIED, one set of 32 bits read two ways. A width too narrow for the number is left out, and a number too large for 64 bits, or below the smallest signed 64-bit value, has no fixed widths at all.

No API

There is no API for this tool. A base conversion is repeated division, run in the browser; most programming languages do it in one call, such as int("ff", 16) in Python.

Privacy

Nothing leaves the browser. Numbers are converted on the page and are not stored or sent. The address bar changes as you type, which puts the number into the browser's history like any other page.