Skip to contentSkip to the inputSkip to the result

Number base converter

Convert binary, octal, decimal and hex

Loading tool

Instructions

Number base converter

How to use

  1. Enter a number and choose its base and the target base.

Supported input

  • Whole numbers up to 200 digits.
  • Prefixes (0x for hex, 0b for binary, 0o for octal) and underscores are read.
  • When the chosen base cannot read a number with a prefix, the prefix picks the base and the result says so.
  • Negatives keep a minus sign.

Input example

255 (decimal)

Result example

FF (hex)

Troubleshooting

  • Values that are not numbers or are out of range are not calculated; the message says what to fix.

Limitations

  • Fractions are not supported.
  • Two's complement is used only when a width of 8, 16, 32 or 64 bits is chosen, and decimal is then the signed value (FFFFFFFF → -1).

How it works

  • Converts whole numbers between binary, octal, decimal and hexadecimal.

Binary, octal and hex without slips: file permissions, signed values and exact big numbers

Jobs it handles

  • Checking what chmod 755 or 644 actually grants before running it on a server
  • Reading a hex dump, an error code or a memory address as a decimal for a bug report
  • Setting and clearing bit flags from a firmware or protocol spec one position at a time
  • Finding out why a value stored as a 32-bit integer suddenly shows up negative

Grouping digits does the arithmetic

One hex digit is exactly four binary digits and one octal digit exactly three, which is why the conversions between them need no real arithmetic. Enter the binary 1111_0000_1010_0101 and each group of four becomes F, 0, A and 5: hex F0A5, decimal 61605, octal 170245. Underscores, commas and spaces put in for readability are removed before reading, so 1,000,000 can go in as written and comes out as hex F4240.

Worked example: what chmod 755 means

  1. 1Enter 755 as octal and convert to binary: 111101101. In decimal it is 493, in hex 1ED.
  2. 2Split it into threes, 111 · 101 · 101. Within each group the bits are read, write and execute, so the owner gets rwx and the group and everyone else get r-x.
  3. 3644 gives 110100100, or 110 · 100 · 100: rw-r--r--, the usual mode for a file only its owner may change.
  4. 4The POSIX chmod specification defines the modes the same way, one bit each: 0400 is read by owner, 0200 write by owner, 0100 execute by owner, and so on down to 0001.

Leading zeros and prefixes

In C and in shell arithmetic, a leading zero makes a number octal, so 0755 is octal there. This tool does not treat a bare leading zero as a prefix: with octal chosen, 0755 is 493, but with decimal chosen it is simply 755, which is octal 1363. Python 3 and JavaScript strict mode reject the leading-zero form for exactly this reason and ask for 0o755 instead.

The 0x, 0b and 0o prefixes are read. With decimal chosen, 0xDEADBEEF is read as hex and the Read as row names the 0x prefix; a prefix after a sign works too, so -0x1f is -31. The chosen base still wins when it can read the text: with hex chosen, 0b12 is made of valid hex digits and comes out as B12, which is 2834.

Same bits, two decimals

  • DEADBEEF in hex is 3735928559 unsigned. Set Negatives to 32-bit and the same bits read as signed give -559038737.
  • In 32 bits, 7FFFFFFF is 2147483647 and the next value up, 80000000, is -2147483648: the sign flips the moment the top bit is set.
  • In 8 bits, -128 and 128 both come out as hex 80, binary 10000000. With a width chosen the tool accepts -128 to 255 and says plainly that -129 does not fit.
  • A chosen width also pads with zeros: 255 in 16 bits is 0000000011111111, hex 00FF.

Exact big numbers, and what is not here

Ordinary JavaScript numbers cannot hold every integer above 2^53, so 9007199254740993 silently becomes 9007199254740992 in code that uses them. This one works in BigInt, and the same number comes out as hex 20000000000001, correct to the last digit.

Numbers with a fractional part such as 1.5 are refused, and only bases 2, 8, 10 and 16 are offered: no base 3 or base 36, no view of floating-point (IEEE 754) bits, and no bitwise operations such as AND, OR or shifts.

Checked

Frequently asked questions

What is binary 1010 in decimal?

Multiply each digit by its power of two and add: 1×8 + 0×4 + 1×2 + 0×1 = 10. In hex it is A, and in octal 12.

Does −1 in hex come out as FFFFFFFF?

Set Negatives to 32-bit and it is written in two's complement, as memory holds it: FFFFFFFF, or FF in 8 bits and FFFFFFFFFFFFFFFF in 64. Read the other way, FFFFFFFF in 32 bits gives decimal -1 and the unsigned value 4294967295. The default, Minus sign, writes -1.

Are very large numbers converted exactly?

Yes, up to 200 digits, with no rounding. 2 to the 64th, 18446744073709551616, becomes hex 10000000000000000 (a 1 followed by 16 zeros), and the bit count, 65, is shown too.