title: Java and unsigned values
body: <p>I'm parsing unsigned bits from a DatagramSocket. I have a total of 24bits (or 3 bytes) coming in - they are: 1 unsigned 8bit integer followed by a 16bit signed integer. But java never stores anything more than a signed byte into a byte/byte array? When java takes in these values, do you lose that last 8th bit? </p>
  
  <pre><code>DatagramSocket serverSocket = new DatagramSocket(666);
          byte[] receiveData = new byte[3]; &lt;--Now at this moment I lost my 8th bit
  
          System.out.println("Binary Server Listing on Port: "+port);
  
          while (true)
          {
              DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
              serverSocket.receive(receivePacket);
              byte[] bArray = receivePacket.getData();
              byte b = bArray[0];
  
          }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/LqMAx.png" alt="enter image description here"></p>
  
  <p>Did I now lose this 8th bit since I turned it into a byte? Was it wrong I initialized a byte array of 3 bytes?</p>