Number base converter

Binary, hex and any base 2–36, two's complement, float bits, Roman and Morse.

Digits 0–9 then a–z. Spaces and underscores are ignored, a minus sign is allowed, 0b/0o/0x work in base 10. One dot starts a fraction.

Result

Binary (base 2)

1111 1111

Octal (base 8)

377

Decimal (base 10)

255

Hexadecimal (base 16)

FF

Base 36

73

What this tool does

Five converters for the ways numbers are written, each in its own tab:

  • Bases. Type a number in any base from 2 to 36 and read it in binary, octal, decimal, hexadecimal and one more base of your choice. Whole numbers are converted with exact big-integer arithmetic, so a 600-digit number comes out right to the last digit. A fractional part is converted exactly too: the digits either end, or a block repeats forever and is shown in brackets.
  • Two's complement. Pick 8, 16, 32 or 64 bits and see the same bit pattern as a signed and an unsigned number, in hex and in binary, with the "invert and add one" steps for a negative value and the pattern sign-extended to wider types.
  • IEEE 754 float. See how a decimal is stored as a 32-bit float or a 64-bit double: sign, exponent, fraction, the kind of value (normal, subnormal, zero, infinity, NaN), every digit of the value actually stored, and the rounding error. It also works backwards, from hex bits to the value.
  • Roman numerals from 1 to 3999 in both directions, with a strict check of the standard form, and the vinculum form up to 3,999,999.
  • Morse code both ways, following ITU-R M.1677-1, with sound you can play at a chosen speed.

How to use the bases tab

  1. Type the number. Spaces and underscores are ignored, so 1111_0000 and FF FF work. A minus sign is allowed.
  2. Choose the base it is written in. In base 10 the prefixes 0b, 0o and 0x switch to binary, octal and hex. In base 16 they are not read as prefixes, because 0b1 is a perfectly good hex number (B1).
  3. Read the results. Binary and hex are grouped in fours from the right, octal and decimal in threes; the copy buttons copy the digits without spaces.

Worked example: 255 is 1111 1111 in binary, 377 in octal, FF in hex and 73 in base 36 (7 × 36 + 3). Decimal 0.1 in binary is 0.0(0011): the block 0011 repeats forever, which is exactly why 0.1 cannot be stored exactly in a binary float. Decimal 3.14 in hex is 3.2(3D70A). If a fraction neither ends nor repeats within 64 digits, it is cut off, not rounded, and marked with "…".

Two's complement and floats, in short

An 8-bit pattern means 0 to 255 when read unsigned, or −128 to 127 when read signed: patterns with the top bit set stand for the value minus 256. So 1111 1011 is 251 unsigned and −5 signed. By hand, −5 is 5 (0000 0101), with the bits inverted (1111 1010), plus one (1111 1011). The tool refuses a value that does not fit, such as 128 in a signed 8-bit type, and names the limits. Widening a negative pattern copies the sign bit: −1 is FF in 8 bits and FFFF in 16.

A float stores a sign, a power of two and a fraction. Typing 0.1 as a float32 gives the bits 3DCCCCCD, whose exact value is 0.100000001490116119384765625, about 1.49 billionths too high. As a double the bits are 3FB999999999999A and the stored value is 0.1000000000000000055511151231257827021181583404541015625. The decimal is rounded once, to the nearest representable value with ties to even, from its exact value. That detail matters for float32: going through a double first can round twice and land one step off, which the tests check with a real example.

For the full story with hand-worked examples, read hex, binary and two's complement explained.

Roman numerals and Morse code

Roman numerals use the standard modern form: I, V, X, L, C, D, M, with only six subtractive pairs (IV, IX, XL, XC, CD, CM). A numeral like IIII or IC is refused with the standard spelling suggested (IV, XCIX). Above 3999 there is no single agreed form; the tool writes the thousands under a bar (the vinculum, ×1000), so 4000 is I̅V̅ and 12,345 is X̅I̅I̅CCCXLV. Some texts write extra M's instead, which is also seen.

Morse follows Recommendation ITU-R M.1677-1: the letters, figures and punctuation of its table, including é and @. The multiplication sign is sent as X and a percent sign as 0/0, as the recommendation says; anything else is listed as having no signal. A dot lasts 1200 ÷ WPM milliseconds, from the standard word PARIS, which is exactly 50 dot lengths. Farnsworth spacing keeps letters fast and stretches only the gaps, which helps when learning to copy by ear.

Everything runs in your browser. For text encodings rather than numbers, see the Base64 encoder; for arithmetic with powers and logs, the scientific calculator; for hex colour codes, the colour tools.

Frequently asked questions

Why does 0.1 not convert to a short binary number?

Because 0.1 is 1/10, and 10 contains the factor 5, which binary cannot divide out. The digits repeat forever: 0.0(0011). A computer must cut that off, so 0.1 is stored as a nearby value, 0.100000001490116119384765625 in a float32.

Is the conversion exact for very large numbers?

Yes. Whole numbers are converted with big-integer arithmetic, so there is no rounding at all, up to 2,000 digits. Fractions are exact as well: the result either ends, repeats (shown in brackets) or is cut off after 64 digits and marked with an ellipsis.

What is the difference between signed and unsigned?

Nothing in the bits, only in how they are read. In 8 bits, 1111 1111 is 255 unsigned and −1 signed in two's complement. A signed 8-bit value runs from −128 to 127, an unsigned one from 0 to 255.

What is a subnormal float?

A number smaller than the smallest normal float, stored with exponent field 0 and no hidden leading 1. It trades precision for range near zero. The smallest float32 subnormal is about 1.4 × 10⁻⁴⁵ (bits 00000001).

How are Roman numerals above 3999 written?

There is no single standard. A common convention puts a bar over a numeral to multiply it by 1000, so 5000 is V̅. The tool uses that for 4000 to 3,999,999 and writes the thousands under the bar.

How fast is 20 words per minute in Morse?

Each dot lasts 1200 ÷ 20 = 60 milliseconds and a dash 180. The word PARIS, with the gap after it, is 50 dot lengths, so 20 of them fill exactly one minute.