Number Base Converter (Binary, Hex, Decimal)
Convert between binary, octal, decimal, hexadecimal and any base, with steps and bitwise operations
Loading the tool…
Converts one number into binary, octal, decimal, hexadecimal and any other base from 2 to 36 at the same time. Use it to check the working of a base conversion exercise or to inspect hex values and bits.
How to use
- Type a number in "Number" and choose its base under "Written in". A 0x, 0b or 0o prefix sets the base automatically.
- The four common bases and "Other base" appear below at once. Fractions are worked out to the number of "Fraction digits".
- Open "Show the working" and choose "Convert to" to see the division and place value steps as tables.
- On "Bits and bitwise", choose the "Width", tap bits to switch them, and see the results of AND, OR, XOR and shifts.
- Use "Binary arithmetic" for carries and borrows, and "Characters ↔ codes" for Unicode code points and UTF-8 bytes.
How it works
- Digits above 9 are written as letters: A = 10, B = 11, up to Z = 35. Whole numbers of any length are converted exactly.
- When fraction digits repeat forever, a line is drawn over the repeating part; … means the digits were cut off.
- The main converter shows negative numbers with a minus sign. Two's complement is shown on "Bits and bitwise" in 8, 16, 32 or 64 bits; a value that does not fit keeps only its lowest bits.
Questions and answers
- How do I convert binary to decimal?
- Multiply each digit by its power of 2 and add the results. For example, 1011 is 8 + 0 + 2 + 1 = 11.
- How do I convert decimal to hex?
- Divide by 16 until the quotient is 0 and read the remainders from the bottom up. 255 gives 15 and 15, so it is FF. "Show the working" shows the same table.
- How does two's complement represent negative numbers?
- Invert all bits of the positive value and add 1. In 8 bits, −42 is 00101010 inverted to 11010101, plus 1, which is 11010110. Signed 8-bit values range from −128 to 127.
- Why does 0.1 not end in binary?
- The denominator 10 has the prime factor 5, which is not a factor of 2. In binary 0.1 is 0.0001100110011…, and the group 0011 repeats forever.