Originally posted by Isabel Wanderley:
I wanna know how I can convert to hex this numbers?? I think that have an easy way to do it that I don't know...
Thanks for any help
Question 6 is as follows.
To answer this question you need to know three things about each of the three data types--byte, short, and char.
First, You have to know the size of the primitive types. Type byte is 8 bits and char and short are both 16 bits.
Second, you need to know that char is an unsigned type and byte and short are signed types.
Third, you need to know the two's compliment representation of the integral primitive types.
Since byte is an 8 bit signed value, then the MAX_VALUE must be represented as follows in binary.
01111111
The sign bit is zero and the rest of the bits are one.
The above binary value is extremely easy to convert to hexadecimal. Each hex digit represents four binary bits so the left four bits represent one hex digit and the right four bits represent the second hex digit.
Binary 0111 1111
Hex 7 f
Char is an unsigned 16 bit value so the binary representation of Character.MAX_VALUE is as follows.
Binary 1111 1111 1111 1111
Hex f f f f
Short is a signed 16 bit value so the binary representation of Short.MAX_VALUE is as follows.
Binary 0111 1111 1111 1111
Hex 7 f f f