Bit manipulation in negative byte and short data types in Java
问题 Im trying to implement a class that stores a 32-bit number without using the int primitive type. For doing so, I'm using two short variables msbs and lsbs to store the 32 bits of the number, 16 bits in each variable. The variable msbs will store the first 16 bits of the number and the lsbs variable the 16 bits left. When It comes to save the given bytes to the variables I apply the next formula: (The bytes order are given as Little-Endian notation) Input -> byte[] n = {0b00110101, -3, 0b1001,