We know that:
2^0=1 2^1=2 2^2=4 2^3=8 2^4=16 2^5=32 2^6=64 2^7=128and so on. To convert the decimal number 75 to binary, we would find the largest power of 2 less than 75, which is 64. Thus, we would put a 1 in the 2^6 column, and subtract 64 from 75, giving us 11. The largest power of 2 in 11 is 8, or 2^3. Put 1 in the 2^3 column, and 0 in 2^4 and 2^5. Subtract 8 from 11 to get 3. Put 1 in the 2^1 column, 0 in 2^2, and subtract 2 from 3. We're left with 1, which goes in 2^0, and we subtract one to get zero. Thus, our number is 1001011.
Try converting these numbers from binary to decimal:
Remember:
2^4| 2^3| 2^2| 2^1| 2^0| | | 1 | 0
| | 1 | 1 | 1
1 | 0 | 1 | 0 | 1
1 | 1 | 1 | 1 | 0
|
Decimal |
Binary |
Hexadecimal |
|
0 |
0000 |
0 |
|
1 |
0001 |
1 |
|
2 |
0010 |
2 |
|
3 |
0011 |
3 |
|
4 |
0100 |
4 |
|
5 |
0101 |
5 |
|
6 |
0110 |
6 |
|
7 |
0111 |
7 |
|
8 |
1000 |
8 |
|
9 |
1001 |
9 |
|
10 |
1010 |
A |
|
11 |
1011 |
B |
|
12 |
1100 |
C |
|
13 |
1101 |
D |
|
14 |
1110 |
E |
|
15 |
1111 |
F |
Converting Decimal to Hex and vice versa
Review the following tutorial on-line:
http://www.math.ohiou.edu/~just/hex.htm
To
convert from Hex to Binary: http://www.permadi.com/tutorial/numDecToHex/
Basic Operations with HEX Numbers
To add two hex numbers
1. convert each number to binary
Hex to Binary
Hex value 6Ch, binary value = 0110 + 1100 = 01101100
2) use binary addition procedure
The addition process for multiple-bit binary numbers:
1010 +1111 ______
Alternately:
11 (carry)
1010 +1111 ______ 11001
3) convert result back to hex
To subtract two hex numbers
1) convert each number to binary
2) use binary subtraction procedure
3) convert result back to hex
We can also do addition in hex itself. This addition is the
same as decimal addition EXCEPT we use a sixteen by sixteen
addition table instead of a ten by 10 addition table, and we
carry (or borrow) sixteen's not ten's.
Hex to Decimal
Hex value 6Ch, decimal value = 6*16 + C*1 = 6*16 + 12*1 = 108
Answers to Binary Problems:
10=(1*2^1) + (0*2^0) = 2+0 = 2
111 = (1*2^2) + (1*2^1) + (1*2^0) = 4+2+1=7
10101= (1*2^4) + (0*2^3) + (1*2^2) + (0*2^1) + (1*2^0)=16+0+4+0+1=21
11110= (1*2^4) + (1*2^3) + (1*2^2) + (1*2^1) + (0*2^0)=16+8+4+2+0=30
Try a few examples of binary addition:
111 101 111
+110 +111 +111
______ _____ _____
Ans1: 1 1
111 111 111
+110 +110 +110
______ ______ _____
1 01 1101
Ans2
1 1 1
101 101 101
+111 +111 +111
_____ ____ _____
0 00 1100
Ans3
1 1 1
111 111 111
+111 +111 111
_____ _____ _____
0 10 1110