title: How can I invert bits of an unsigned byte in Java?
body: <p>I am trying to write a decoder for a very simple type of encryption. Numbers from 0-255 are entered via Scanner, the bits are inverted, and then converted to a character and printed. </p>
  
  <p>For example, the number 178 should convert to the letter "M". </p>
  
  <p>178 is 10110010. </p>
  
  <p>Inverting all of the bits should give 01001101, which is 77 or "M" as a character.</p>
  
  <p>The main problem I have is that, as far as I can tell, Java does not support unsigned bytes. I could read values as an int or a short, but then the values will be off during the conversion due to the extra bits. Ideally I could just use the bitwise complement operator, but I think I will end up getting negative values if I do this with signed numbers. Any ideas on how I should approach this?</p>