Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

binary to decimal tip

how to convert binary to decimal in your mind very easily

You only need to remember 2 things:

(1) the first 8 numbers:
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7

(2) shifting to left by one digit multiplies the number by 2 (10b):
1010 = 101 x 10 = 5 x 2 = 10
10100 = 101 x 100 = 5 x 4 = 20
101000 = 101 x 1000 = 5 x 8 = 40

When you see something like 101011, you can process it this way:
101011 = 101000 + 11 = 5 * 8 + 3 = 43

1110101 = 7 * 16 + 5 = 117
and so on.

It is easier than it looks at first glance :)

source: vik korneev at http://catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/

most viewed