DevKit Tools

Number Base Converter

Convert between binary, octal, decimal and hexadecimal with exact big integer maths and a bit by bit breakdown.

Numbers/Number Base Converter

Convert between binary, octal, decimal and hexadecimal, with bit inspection and no precision loss.

Conversions

Binary11111111
Octal377
Decimal255
Hexff

Bits (8 needed, shown padded to 8)

11111111

Fits in a uint8. Conversion uses BigInt, so values beyond 2^53 stay exact.

Binary       11111111
Octal        377
Decimal      255
Hexadecimal  ff

Bits needed  8
Fits in      uint8

About the number base converter

Base conversion is simple until the number is large. JavaScript loses precision past 2^53, so a converter built on ordinary numbers quietly returns the wrong answer for a 64 bit value, which is exactly the size you are most likely to be converting.

This uses big integer arithmetic, so the result stays exact at any size. The bit view alongside shows which bits are set, which is the part you usually want when you are debugging a flag field or a permission mask.

How to use it

  1. 1Enter a value, with or without a 0x, 0b or 0o prefix.
  2. 2Pick the input base, or rely on the prefix to override it.
  3. 3Read the conversions and the bit breakdown.
  4. 4Copy the snippet for your language.

Questions

Does it handle very large numbers?

Yes. It uses BigInt, so 64 bit values and beyond stay exact. Converters built on ordinary JavaScript numbers start losing precision above 2^53.

Do I need to select the right base?

Only when there is no prefix. A leading 0x, 0b or 0o is unambiguous and overrides the dropdown.

Why is the binary padded?

To whole bytes, because that is how the value is actually stored and it makes a flag field far easier to read. The real bit count is shown beside it.

What does 'fits in uint8' mean?

The smallest unsigned integer type that can hold the value. Useful when picking a column type or a struct field.

More Calculators tools