Australian Jeevitham TECHDeveloper tools

Tech / Number Base Converter

Number Base Converter

Convert a number between binary, octal, decimal, hex and any base up to 36, with grouped bits and two's complement for negative values.

Type in any box

Details

Nothing to show yet.

Whole numbers of any size are supported, including negative numbers.

Binary, octal, decimal and hex

These are four ways of writing the same number. Decimal 255 is FF in hex, 1111 1111 in binary and 377 in octal. Computers work in binary, and hex is the handy short form: each hex digit stands for exactly 4 bits, so one byte is always two hex digits.

Where you will see each base

  • Hex - colours such as #EE4A23, memory addresses, network MAC addresses and Unicode codes (the Malayalam letter അ is U+0D05).
  • Binary - flags and bit masks, and subnet masks in networking.
  • Octal - Linux file permissions such as 755.
  • Base 36 - uses 0-9 and a-z, so it makes short IDs, such as in link shorteners.

What do 0x, 0b and 0o mean?

They are prefixes that show the base in code: 0xFF is hex, 0b1010 is binary and 0o755 is octal, in languages such as JavaScript and Python. You can paste numbers with these prefixes into the boxes above.

How are negative numbers stored?

Most computers use two's complement. In 8 bits, -1 is stored as 1111 1111 (0xFF), which is why the same bits can mean -1 or 255 depending on the type. Type a negative number to see its two's complement form in the details.

Very large numbers

Normal JavaScript numbers lose accuracy above 9,007,199,254,740,991 (253 - 1). This page uses JavaScript's BigInt for whole numbers, so even very long IDs and 64-bit values convert exactly.