01 / Place value
Each digit has a weight
In base 10 the places are worth 1, 10, 100. In base 2 they are worth 1, 2, 4, 8. In base 16 they are worth 1, 16, 256.
Free tool
Type a number and see it in binary, octal, decimal and hexadecimal at once, plus any other base from 2 to 36. Numbers can be as long as you like, because nothing is rounded. Pick a bit length to see two's complement, turn on fractions, group the digits, and open the steps to see how one conversion is done by hand. A number that is also a character, like 65, is shown as text.
Two's complement
The steps
Options
A 0x, 0b or 0o in front sets the base for you. Spaces and underscores inside a number are ignored. Settings are remembered in this browser.
Converted in your browser. Nothing is sent anywhere.
How it works
01 / Place value
In base 10 the places are worth 1, 10, 100. In base 2 they are worth 1, 2, 4, 8. In base 16 they are worth 1, 16, 256.
02 / Exact
Whole numbers use arbitrary-size integers, so 2 to the power of 64 comes out digit for digit, not as 1.8e19.
03 / Steps
Open the steps to see the place values added up, or the divisions by the base and the remainders that make the answer.
Guide
A number base converter rewrites one number using a different set of digits. Binary uses two digits, octal eight, decimal ten and hexadecimal sixteen, but the number itself does not change. This converter shows binary, octal, decimal and hex together, handles any base from 2 to 36, keeps every digit of very large numbers, and can show a number as a two's complement bit pattern of the length you choose. It answers binary to decimal, decimal to hex, hex to binary and every other pair in one box.
Each binary digit is worth a power of two, counting from the right: 1, 2, 4, 8, 16, 32 and so on. Add the values where the digit is 1. Take 101101: that is 32 + 8 + 4 + 1, which is 45. The steps panel lays this out as a table of digit, place value and digit times place value.
Going the other way, divide by the new base again and again and keep the remainders. For 45 to binary: 45 / 2 = 22 remainder 1, 22 / 2 = 11 remainder 0, 11 / 2 = 5 remainder 1, 5 / 2 = 2 remainder 1, 2 / 2 = 1 remainder 0, 1 / 2 = 0 remainder 1. Read the remainders from the bottom up and you get 101101. The same method gives hex with 16: 4660 / 16 = 291 remainder 4, 291 / 16 = 18 remainder 3, 18 / 16 = 1 remainder 2, 1 / 16 = 0 remainder 1, so 4660 is 0x1234.
One hex digit is exactly four binary digits, so you can convert in groups. 1101 is D and 0110 is 6, so 11010110 is D6 in hex, which is 13 x 16 + 6 = 214 in decimal. Octal works the same way with three bits per digit. That is why hex is the usual way to write binary compactly.
Computers store negative whole numbers in two's complement. Pick a bit length, then flip every bit of the positive number and add 1. For -5 in 8 bits: 5 is 00000101, flipped it is 11111010, and adding 1 gives 11111011, which is 0xFB. The same pattern read as unsigned is 251. The converter shows both readings and the range for the length you chose, and says so when a number does not fit.
| Bits | Unsigned range | Signed range |
|---|---|---|
| 8 | 0 to 255 | -128 to 127 |
| 16 | 0 to 65,535 | -32,768 to 32,767 |
| 32 | 0 to 4,294,967,295 | -2,147,483,648 to 2,147,483,647 |
A number with a point can be exact in one base and endless in another. 0.1 in decimal becomes 0.000110011001... in binary, a pattern that repeats forever, which is why 0.1 + 0.2 is not exactly 0.3 in most programming languages. The converter cuts the digits off after the number of places you set and tells you when it did. Multiplying the fraction by the new base and keeping the whole part, one digit at a time, is the method shown in the steps.
Whole numbers are not rounded. 18446744073709551616, which is 2 to the power of 64, becomes 1 followed by sixteen zeros in hex. A number up to 20,000 digits long is accepted.
Bases above 10 use letters for the digits after 9: a is 10, b is 11 and z is 35, so base 36 uses every letter. In base 36, zz is 35 x 36 + 35, which is 1295. When the number is also a character code, the Character row shows it, so 65 is A. When a long hex number is made of UTF-8 bytes, the Bytes as text row shows the words. For a full text translator, use the binary translator.
For colours, the hex to RGB converter turns a hex code into red, green and blue.
Questions
Choose Binary under From base, paste the ones and zeros, and read the Decimal row. By hand, add the powers of two where there is a 1: 101101 is 32 + 8 + 4 + 1 = 45.
Leave From base on Decimal and read the Hexadecimal row. By hand, divide by 16 and keep the remainders: 4660 gives 0x1234.
Up to 20,000 digits. Whole numbers are exact, with no rounding, so 18446744073709551616 converts digit for digit.
The way computers write negative whole numbers in a fixed number of bits. Flip the bits of the positive number and add 1. In 8 bits, -5 is 11111011.
A fraction that ends in one base can repeat forever in another. 0.1 is endless in binary. The converter stops after the places you set and says it did.
They are prefixes used in code for hex, binary and octal. Type one in front of a number and the converter sets From base for you.
Any whole base from 2 to 36. Digits above 9 are the letters a to z.
No. The maths runs in your browser.