A. Introduction
Turn a binary number into decimal is easy: just multiply each digit with its place value and add up. e.g. 1101 = 1*2^3 + 1*2^2 + 0*2^1 + 1*2^0 = 8+4+1=13
B. Two ways to turn decimal into binary:
Divide the number by 2 until the quotient is 0, then write down all the remainder backwards.
2. Descending power of 2 and subtract:
Find the largest power of 2 that can fit in the decimal number x, let that be n. If x>2^n, note down 1 (from highest to lowest, i.e. left to right) otherwise note down 0.
x = x - 2^n
n=n-1 if n>=0, go back to step 1; otherwise done.
C. Try:
Convert the following binary numbers into decimal numbers:
1011, 1101, 1111, 10001, 11001, 1100010011, 1000111011.
Convert the following decimal numbers into binary numbers:
123, 789, 9021, 8762, -1000000, 0.5
11, 13, 15, 17, 25, 787, 571
1111011, 1100010101, 10001100111101, 10001000111010, -11110100001001000000, 0.1
1)2^3+2^1+2^0=11
2)2^3+2^2+2^0=13
3)2^3+2^2+2^1+2^0=14
4)2^4+2^0=17
5)2^4+2^3+2^0=25
6)2^9+2^8+2^4+2^1+2^0=787
7)2^9+2^5+2^4+2^3+2^1+2^0=571
8)111101
9)1100010101
10)10001100111101
11)10001000111010
12)-11110100001001000000
13)0.1