This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "change java byte to unsigned" Watch "change java byte to unsigned" New topic
Author

change java byte to unsigned

sweety mehra
Greenhorn

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.

Example:


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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: change java byte to unsigned
 
Similar Threads
Convert small C routine to Java
shift operators and hex...HELP!!!!!
final variable.
Bitwise OR
Reading unicode characters from a file