Originally posted by Mikael Jonasson:
Try casting it.
/Mike
Dave
Originally posted by Dave Vick:
If I understand correctly you're trying to take the 0xFF value and put it into a byte then later be able to put the byte into a long and get the 0xFF value back out.
Originally posted by Dave Vick:
All of the other bits are lost and can't be reclaimed, that's why you couldn't convert it back and get the value 255 after turning it into a long.
Dave
Originally posted by Dave Vick:
hope it helps
Originally posted by Mohan K:
char c = 0xffff ; // your input stream
long l = 0x00ff & c ;
System.out.println("l = c & 0x00ff: l = " + l); //255
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|