Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes change java byte to unsigned Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "change java byte to unsigned" Watch "change java byte to unsigned" New topic

change java byte to unsigned

sweety mehra

Joined: Feb 09, 2007
Posts: 9
Since java byte is signed, so is there any method to change java byte to unsigned
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Well, there aren't any unsigned types in Java, so what do you mean?

When you assign an integral type to a larger integral type, Java will sign-extend it. If you then zero-out the higher-order bits, then you have an integer with the value that would have been represented by the smaller type, if it were unsigned.


Is that what you meant?
[ February 12, 2007: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: change java byte to unsigned
It's not a secret anymore!