Quantcast Convert octal to hex, w/out converting to Binary Text - Physics Forums Library

PDA

View Full Version : Convert octal to hex, w/out converting to Binary


NW8800
Aug7-08, 10:09 AM
I am trying trying to convert a from octal to hex and hex to octal without using binary/dec transform using repeated divison... Logically I thought I could use the hex base in octal for repeat division which is 20 oct

Example of problem I am trying to solve,

Convert 326 octal to hex (ans 0xD6)


326 oct / 20 oct = 16 oct remainder 6 oct = 0x6

16 oct / 20 oct = 0 oct remainder 16 oct = 14 dec = 0xE!!??

Reading UP^ most sig to least gives me 0xE6 not D6 i.e. im off by 1 hex char..?

Another example 372 oct

372oct /20 oct = 18 r 12
18/20 = invalid octal number lol!

Also how would I do hex straight to octal I.e. E7C -> oct?



Please help...