Binary Converter: Convert Between Binary, Decimal, Octal and Hex
Type any number, say which base it is written in, and get all four representations at once, plus the bit length and the signed versus unsigned reading of the decimal value.
Type any number, say which base it is written in, and get all four representations at once, plus the bit length and the signed versus unsigned reading of the decimal value.
A binary converter turns a number from one base into another. Enter a value in binary, decimal, octal or hexadecimal and see it in all four at once.
Binary uses only two digits, 0 and 1. Each digit is called a bit. Computers use it because a circuit is easily either off (0) or on (1). Everyday decimal uses ten digits, but the idea is identical: the position of a digit decides how much it is worth.
In binary, each position is worth a power of 2, starting from 1 on the right: 1, 2, 4, 8, 16, and so on. To convert to decimal, add up the weights wherever there is a 1.
Worked example: 1011 binary to decimal
8 + 0 + 2 + 1 = 11. So 1011 in binary is 11 in decimal.
To go the other way, divide the decimal number by 2 repeatedly and note each remainder. Read the remainders from last to first. For 11: 11 ÷ 2 = 5 remainder 1, 5 ÷ 2 = 2 remainder 1, 2 ÷ 2 = 1 remainder 0, 1 ÷ 2 = 0 remainder 1, reading backwards gives 1011.
For checking the arithmetic along the way, a scientific calculator handles powers of 2 quickly.
Hex is popular because one hex digit equals exactly four bits, which makes long binary strings much shorter to read.
Bit length is how many bits a number is stored in. An 8-bit value has 256 possible combinations, so unsigned (no negatives) it covers 0 to 255. Signed numbers reserve the leftmost bit to show positive or negative, usually using a method called two's complement. An 8-bit signed value then covers -128 to 127. The same bits can mean different numbers depending on which type is used, so always know which one you are working with.
If you also work with ratios while handling data sizes, the percentage calculator can help.
It is 10. The weights are 8 + 0 + 2 + 0.
Hardware reliably distinguishes two states, on and off, so binary is the simplest dependable way to store and process data.
Base 16 needs sixteen symbols. After 0-9, the letters A-F stand for 10 through 15.
Yes. Signed formats such as two's complement use the leftmost bit to mark the sign.
256, since 2 to the power of 8 is 256.