Yueseryueser.com

← All guides

Number Base Converter Guide: Decimal, Binary, Octal, Hex at Once

Changing base is easy. The hard part is knowing whether you are looking at a number or at a string of bytes. This tool handles numbers.

Open the tool:Number Base Converter

Everyday hardware and permission work

A register manual says 0x1F and your code needs bit 5. Linux permissions are octal, so 755 is not decimal. A design file gives a hex colour that CSS splits into three bytes. All of these require moving between bases.

Bit masks make it obvious: 1 shifted left by 4 is 16, which is 0x10, which is 0b10000. Seeing all four side by side beats converting in your head, especially when a single wrong digit changes behaviour.

Prefixes and precision

0x means hexadecimal, 0b means binary, and anything else is decimal. Do not use thousands separators: a comma inside the number makes it invalid input here, and neither should you add spaces. There is no dedicated octal prefix; parsing follows JavaScript number syntax, so 0o forms usually work too.

All arithmetic uses JavaScript numbers, whose safe integer limit is 2^53 − 1, or 9007199254740991. Beyond that, the last digits change silently. For exact 64-bit IDs or hash prefixes, use BigInt or a tool built for arbitrary precision.

Boundary: truncation, width, and byte order

Fractional input is truncated to an integer, because the output lists integers only. Negative numbers and scientific notation depend on how the input is parsed, so verify the result if you rely on them. The tool also does not pad to 8, 16, or 32 bits; add leading zeros yourself.

It says nothing about byte order. As a number, 0x1234 is 4660, but in memory it may be 12 34 or 34 12 depending on the machine and protocol. Confusing the two is one of the most common causes of communication bugs.

FAQ

Why did the last digits of a big number change?

The value is held as a double-precision float, which cannot represent integers beyond 2^53−1 exactly. That is a limit of the number type, not of the conversion. Use BigInt or an arbitrary-precision tool for 64-bit values.

Are the 0x and 0b prefixes required?

Yes, if you want that base. Without a prefix the input is read as decimal, so a bare hex string fails and 0x1F gives 31. Hex digits may be upper- or lowercase.

Why did the decimal part disappear?

The output lists integers only, and the fraction is truncated rather than rounded. If you need fractions, first decide how the target base should represent them, then use a tool that supports fractional output.

Related tool:Number Base Converter