Hi! I have the problem where I cast a bit string of "10000000" to a
byte, which i get -128; this is fine so far. However, when I take this byte
and cast it to a char, I get a question mark('?'). So when i go to cast it
back to a byte, i now get 63 (the ascii representation of a question mark).
I see that for any byte from 128 to 256 i'll get a question mark... must be
java's way of indicating that's it's negative or something.... my
question to you all is:
1) Why is it doing this?
2) What can I do so that I can cast -128 to char and back to a byte to
get -128 again?
Thanks!
byte, which i get -128; this is fine so far. However, when I take this byte
and cast it to a char, I get a question mark('?'). So when i go to cast it
back to a byte, i now get 63 (the ascii representation of a question mark).
I see that for any byte from 128 to 256 i'll get a question mark... must be
java's way of indicating that's it's negative or something.... my
question to you all is:
1) Why is it doing this?
2) What can I do so that I can cast -128 to char and back to a byte to
get -128 again?
Thanks!
Comment