This week's book giveaway is in the Jobs Discussion forum. We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line! See this thread for details.

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.

Parimala Somasundaram
Ranch Hand

Joined: Mar 31, 2001
Posts: 41

posted

0

Thanks Manfred. Is the reverse(converting Binary to Hex or Octal and decimal to Hex or Octal) true as you have explained? That is to convert decimal to hex first convert to binary and then to hex by grouping in fours? If the binary# is say 100011100 how to we group to convert to hex or octal?

To convert binary to Hex, group the binary digits from the right by 4s. 0110011 = 011 0011 = hex 33 To convert binary to Octal, group the binary digits from the right by 3s. 0110011 = 0 110 011 = octal 63