posted 23 years ago
Hi Parimala,
Hex/Octal to Binary:
binary digits from for rightmost digits:
2**3, 2**2, 2**1, 2**0
8, 4, 2, 1
Use the above numbers to add up values until it equals the given number.
Hex: uses four binary digits to represent one value.
0 - 9, A (10), B (11), C (12), D (13), E (14), and F (15)
Try it: 0x4A
Answer: 0100 1010
Octal: uses three binary digits to represent one value.
0 - 7
Try it: 073
Answer: 111 011
----------------------------------------------------------------
Binary to Decimal:
Using what we have already learned:
Try it: 111 011
1*(2**0) + 1*(2**1) + 0*(2**2) + 1*(2**3) + 1*(2**4) + 1*(2**5)
1 + 2 + 0 + 8 + 16 + 32 = 59
Try it: 0100 1010
0*(2**0) + 1*(2**1) + 0*(2**2) + 1*(2**3) + 0*(2**4) + 0*(2**5) + 1*(2**6) + 0*(2**7)
0 + 2 + 0 + 8 + 0 + 0 + 64 + 0 = 74
----------------------------------------------------------------
Octal to Decimal:
Using the same position stuff as binary above we use 8 instead of 2.
Try it: 073
3*(8**0) + 7*(8**1)
3 + 56 = 59
----------------------------------------------------------------
Hex to decimal
Using the same as above except use 16 instead of 8.
Try it: 0x4A
A*(16**0) + 4*(16**1)
10*1 + 4*16 = 74
Enjoy,
Manfred.