Developer Bases

Binary to decimal

Binary value
Decimal 170
Each place is a power of two
The same number elsewhere
Binary 10101010
Binary, grouped 1010 1010
Octal 252
Hexadecimal AA
Bits needed 8
Note
Places double: 1, 2, 4, 8, 16…
DecimalBinaryOctalHex
0000
1111
81000108
10101012A
15111117F
16100002010
64100000010040
100110010014464
25511111111377FF
256100000000400100
1024100000000002000400
655351111111111111111177777FFFF

From the right, the places are 1, 2, 4, 8, 16, 32, 64, 128. Add the ones where a bit is set: 10101010 has bits at 128, 32, 8 and 2, which totals 170. With practice a byte is readable directly, which is why the eight powers of two up to 128 are worth memorising.

Advertisement
320 × 100

Each binary place is a power of two, doubling from the right: 1, 2, 4, 8, 16 and so on. Add the values where a bit is set. 10101010 is 128 + 32 + 8 + 2 = 170.

How to convert binary to decimal

1 Enter the binary digits. Spaces, underscores and commas between groups are ignored, and a 0b prefix is accepted.
2 Read the decimal value, with the hex and octal forms beneath it.
3 Check the bits row for the width — leading zeros are not counted.
4 Anything other than 0 and 1 is named as an error rather than skipped over.

Grouping matters more than it looks. A long binary string is nearly unreadable, which is why it is conventionally written in groups of four or eight. 11001010 rather than the same eight digits run into their neighbours. Four bits is a nibble and maps to one hex digit; eight is a byte and maps to two. Read that example by its places: 128 + 64 + 8 + 2 = 202.

The conversion here reads the bits as an unsigned magnitude, and that assumption is the thing to check. 11111111 comes out as 255. If those eight bits came out of a signed byte, the top bit is a sign bit and the identical pattern means −1. Nothing in the digits says which reading is right; you have to know what produced them, and if the answer is a signed field, the two’s complement calculator is the tool that reads it properly.

The useful sanity check is the width: n bits hold values up to 2ⁿ − 1, so eight bits stop at 255 and sixteen at 65535, and a run of n ones is always exactly that maximum. If a decimal result is larger than the digit count allows, you have miscounted the bits somewhere.

Questions

Ten. The places are 8, 0, 2, 0.

Advertisement
300 × 250
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding