Skip to content

Instantly share code, notes, and snippets.

@codepedia
Created June 21, 2019 03:17
Show Gist options
  • Save codepedia/63c3fc490b66bd42aad801927f3172e4 to your computer and use it in GitHub Desktop.
Save codepedia/63c3fc490b66bd42aad801927f3172e4 to your computer and use it in GitHub Desktop.
byte[] IFD_Address_tmp = Arrays.copyOfRange(bytes, 4, 8);
int IFD_Address = 0;
int i = 0;
int shiftBy = 0;
for (shiftBy = 0; shiftBy < 32; shiftBy += 8) {
IFD_Address |= ((long) (IFD_Address_tmp[i] & 0xff)) << shiftBy;
i++;
}
& 0xff is required to capture the 8 bits into an integer;
<< shifts the bits to the left to select the appropriate place in IFD_Address;
|= sets the bits in IFD_Address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment