# Calculating hex to dec and bin quickly

We all know how to convert simple binary to dec and vice versa but what about hex? and what if we don’t have a calculator handy?

Let’s take a simple hex address abcd

The easiest task is to convert it to binary:

a (dec 10) is in binary 1010   because the first 1 stands for 8, next 0 stands for 4, 1 stands for 2, 0 stands for 1, so 8+2 = 10, or a in hex

b (dec 11) is in binary 1011 because the first 1 stands for 8, next 0 stands for 4, 1 stands for 2, 1 stands for 1, so 8+2 + 1= 11, or b in hex

So abcd will be:

1010101111001101

So we have a 16-digit binary number.
The first digit in a 16 digit binary number stands for 32768, next one for 16384, next one for 8192. So we have

SUM

1×32768

0x16384

1×8192               40960

0x4096

1×2048               43008

0x1024

1×512              43520

1×256             43776

1×128             43904

1×64                43968

0x32

0x16

1×8                  43976

1×4                 43980

0x2

1×1                   43981

So abcd is 43981 in dec or 1010101111001101 in binary.

So if you don’t have a calculator handy, you can just use a piece of paper to calculate hex to binary in a few seconds and then to dec in under a minute. Obviously, some numbers will be easier to calculate than others, e.g. a000 is in binary 1010000000000000 so you know it’s simply 32768 + 16384 = 49152. It’s like with simple multiplication, where after a while you don’t need to calculate how much is 6×8, because you’ve internalized the result.

other examples:

ef

11101111

This one is very easy, because you know that 11111111 is 255, and a zero in the fifth position is 16 so it’s easier to deduct than to add.  So 255-16=239.

Similarly

feff

1111111011111111

we know that ffff is 65535 and zero is in the eighth position (256). <eight because the first from the right is actually 2 to the power of 0 = 1> So feff is

65535 – 256  OR

65535 – 235 – 21 !!!easier to calculate!!!

= 65279