To convert an int back to a byte, just use a cast: (byte)someInt . The resulting narrowing primitive conversion will discard all but the last 8 bits. Also, bear in mind that you can't use byte type, doing so will result in a signed value as mentioned by other answerers.
How to Convert Int to Unsigned Byte and Back - Stack Overflow
stackoverflow.com > questions > how-to-convert-int-to-unsigned-byte-and-...
You can just do this: array = (byte)package. FrameID; array = (byte)(package. FrameID >> 8);
Convert a ushort value into two byte values in C# - Stack Overflow
stackoverflow.com > questions > convert-a-ushort-value-into-two-byte-val...
The int and unsigned int types have a size of four bytes.
Data Type Ranges | Microsoft Docs
docs.microsoft.com > en-us > cpp > cpp > data-type-ranges
For unsigned byte , the allowed values are from 0 to 255 . Java doesn't have unsigned bytes (0 to 255). To make an unsigned byte, we can cast the byte into an int and mask (bitwise and) the new int with a 0xff to get the last 8 bits or prevent sign extension.
Java - Convert bytes to unsigned bytes - Mkyong.com
mkyong.com > java > java-convert-bytes-to-unsigned-bytes