Originally posted by May Yoong Cheah:
I know that it is easy to convert a small number like 1 to hex which is 0x0001.
But how do you convert a big number like 2147483647 to hex? Is there a formula that I can follow? And I am wondering if in the exam they will test you on converting big numbers to hex.
You can do a search through this forum and find lots of threads that deal with this.
I find that the best method is to continutally divide the number by the base you want to convert to. Then, the remainders make up the value in the new base. Like this:
Then, your answer is the remainders, in reverse order:
2147483647 = 0x7FFFFFFF
You can do the same to convert to binary - just divide by 2 instead of 16.
Of course, I can't imagine them giving you a number this nasty to do on the exam - the math would take too long.
I hope that helps,
Corey