Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

change java byte to unsigned

 
sweety mehra
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since java byte is signed, so is there any method to change java byte to unsigned
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic