I have an integer
int a = //...
int
s in java consist of 4 bytes. If we cast it to short
, we will take two least significant bytes. What is the fastest way to get short
consisting of 2 most significant byte
s of the int
?
short b = //take two most significant bytes of a
short b = (short) (a >> 16);