# Hexadecimal

TimD Moore

Greenhorn

Posts: 14

posted 12 years ago

the trick with hex is to turn into binary (which is actually easier to do than Decimal) -- and then figure out what that binary number is.

So... we've got these 2 numbers: 0xFFFFFFFC and 0xFFFFFFDF

So... now that I've done that one for ya -- can you figure out the other?

Grab a piece of scrap paper and count from 0-15 in binary and that will help you to convert the Hex digits to its binary equivalent.

[ August 19, 2003: Message edited by: Jessica Sant ]

So... we've got these 2 numbers: 0xFFFFFFFC and 0xFFFFFFDF

So... now that I've done that one for ya -- can you figure out the other?

Grab a piece of scrap paper and count from 0-15 in binary and that will help you to convert the Hex digits to its binary equivalent.

[ August 19, 2003: Message edited by: Jessica Sant ]

- Jess

Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep

TimD Moore

Greenhorn

Posts: 14

posted 12 years ago

That's a big help. I'm not sure if I have it 100% but that well get me going well on my way.

Thanks Alot,

TM

Thanks Alot,

TM

TimD Moore

Greenhorn

Posts: 14

posted 12 years ago

Decimal to Hex is a little trickier..

You can check out this thread for some instruction about how:

http://www.coderanch.com/t/242789/java-programmer-SCJP/certification/Octal-hexadecimal-representation

BUT -- the good news is, converting Decimal -> Hex is not on the exam. So look into it if you're curious... but don't sweat it. Go study Threads some more, it'll be time better spent.

Bascially you should know that HEX numbers start with 0x, Octal numbers start with 0, Decimal numbers start with anything 1-9. And remember, the x in Ox can be capitalized too -- so OXDEAFCAB is the same as OxDeafCab is the same as Oxdeafcab --

You can check out this thread for some instruction about how:

http://www.coderanch.com/t/242789/java-programmer-SCJP/certification/Octal-hexadecimal-representation

BUT -- the good news is, converting Decimal -> Hex is not on the exam. So look into it if you're curious... but don't sweat it. Go study Threads some more, it'll be time better spent.

Bascially you should know that HEX numbers start with 0x, Octal numbers start with 0, Decimal numbers start with anything 1-9. And remember, the x in Ox can be capitalized too -- so OXDEAFCAB is the same as OxDeafCab is the same as Oxdeafcab --

Corey McGlone

Ranch Hand

Posts: 3271

posted 12 years ago

In order to convert decimal to any base (hex, octal, or binary), you can continually divide the number by the base. Let me give you an example by converting the number 95 to all 3 bases.

First, we'll do binary:

Now, write down the remainders in reverse order that you got them: 1011111. There you have it - 1011111 is the binary version of 95. Let's try that with hex:

Again, we write down the remainders in reverse order and we have 0x5F, which is the hexadecimal representation of 95. Finally, let's do octal:

That gives us a value of 137, which is the octal representation of 95.

I hope that helps,

Corey

First, we'll do binary:

Now, write down the remainders in reverse order that you got them: 1011111. There you have it - 1011111 is the binary version of 95. Let's try that with hex:

Again, we write down the remainders in reverse order and we have 0x5F, which is the hexadecimal representation of 95. Finally, let's do octal:

That gives us a value of 137, which is the octal representation of 95.

I hope that helps,

Corey