Public static byte [] int32ToBytes(int val) {
int size = Integer。 Size/byte. Size;
Byte[] ret = new byte [size];
for(int I = 0; I< size; ++i) {
Ret[i] = (bytes) (val<& lt(8 * i)>& gt56);
}
Return to ret
}
Extended data
Java also provides byte data type, which is a basic type. Java byte is regarded as the smallest number, so its value range is defined as-128~ 127, that is, signed byte.
Byte, byte, consists of 8-bit binary. In Java, byte data is an 8-bit signed binary number. In computer, the range of 8-bit signed binary number is [- 128, 127], so in Java, the range of byte type is also [- 128, 127].
Operating rules:
# # # # The highest bit of a positive number is 0, and the value of a positive number is a binary value. ####
# # # # The highest digit of a negative number is 1, and the value of a negative number is obtained by adding 1 and then the minus sign. ####