← Developer

Number Base Converter

Convert between binary, octal, decimal, hexadecimal, and any base from 2 to 36, with exact fractions, big integers, and an editable two's complement bit view.

Input

Sign, fraction point, and 0x / 0b / 0o prefixes are allowed; spaces, underscores, and commas between digits are ignored.

Try one

255 1010.1 (binary) ff.8 (hex) −1 0755 (octal) 0.1 2^64 zz (base 36)

Conversions

Decimal
–
Binary–
Octal–
Decimal–
Hexadecimal–
Base 36–
Base 12–
Bits needed
–
Hex digits
–
Character
–

Two's complement

MSB (sign bit, dashed)LSB
Signed reading–
Unsigned reading–
Hex pattern–
Range for this width–

Click a bit to flip it; the input updates to the new signed value.

About this tool

This number base converter takes a value in binary, octal, decimal, hexadecimal, or any base from 2 to 36 and shows it in all the others at once, including base 36 and a custom base of your choice. It handles signed numbers, fractional parts (the digits after the point are converted exactly, to as many places as you ask for), and integers of any size, because the arithmetic is done with BigInt rather than floating point, so a 40-digit decimal converts to hex without losing a digit. A two's complement panel shows the value as an 8, 16, 32, or 64-bit pattern that you can edit bit by bit, with the signed and unsigned readings side by side, and small values are annotated with their ASCII or Unicode character. It is for programmers reading memory dumps and flags, students learning positional notation, and anyone who needs to check a hex color, a file permission, or a network mask.

How it works

The input is split into sign, integer digits, and fraction digits and each digit is validated against the chosen base. The integer part is accumulated as a BigInt (value = value × base + digit), so there is no size limit and no rounding. The fraction is kept as an exact rational number, numerator over base^k for k fraction digits, and converted to another base by repeatedly multiplying the numerator by the target base and taking the whole part as the next digit, stopping at the requested number of digits and flagging when the expansion has not terminated (0.1 in decimal is a repeating binary fraction, for example). Binary output is grouped in nibbles of 4 bits. The two's complement view reduces the integer modulo 2^width: a negative value v is shown as 2^width + v, and the pattern is read back as signed by subtracting 2^width when the top bit is set. Prefixes 0b, 0o, and 0x are accepted for their bases, and spaces, underscores, and commas between digits are ignored.

Frequently asked questions

Why does 0.1 in decimal become a repeating fraction in binary?

A fraction terminates in a given base only when its denominator, in lowest terms, has no prime factors other than the base's. 0.1 is 1/10, and 10 = 2 × 5; since 5 is not a factor of 2, the binary expansion 0.000110011001100... repeats forever. This is exactly why 0.1 + 0.2 is not exactly 0.3 in floating-point arithmetic. The tool shows as many digits as you request and marks the result as truncated.

What is two's complement and why does −1 show as 11111111?

Two's complement is how nearly every CPU stores signed integers. In an n-bit word, a negative number v is stored as 2^n + v, so in 8 bits −1 is 256 − 1 = 255 = 11111111 and −128 is 10000000. The top bit acts as the sign, and addition works with the same circuit for signed and unsigned values. The same 8 bits therefore read as 255 unsigned or −1 signed; the panel shows both.

How large a number can this convert?

There is no fixed limit for integers: arithmetic uses JavaScript BigInt, which grows as needed, so a 100-digit decimal number converts exactly. Fractions are exact too, kept as a numerator over a power of the input base, and converted digit by digit up to the number of fraction digits you choose (20 by default, up to 60). The only practical limit is how long the page takes to render very long strings.

What are the 0x, 0b, and 0o prefixes?

They are the conventional markers for hexadecimal, binary, and octal literals in C, Python, JavaScript, Rust, and most other languages: 0xFF is 255, 0b1010 is 10, and 0o755 is 493. The converter accepts each prefix when the matching base is selected. Note that a bare leading zero meant octal in older C and shells (0755), a convention that still applies to chmod modes.

Related tools

JSON Formatter · Base64 Encode / Decode · URL Encode / Decode · Regex Tester · Hash Generator · UUID Generator · JWT Decoder · HTML Entity Encoder · Color Converter · Password Generator · QR Code Generator · Chmod Calculator

Browse all Developer Tools, or go back to every free tool on HeroYears.