Skip to content

Instantly share code, notes, and snippets.

@herbertdai
Last active December 27, 2015 03:38
Show Gist options
  • Save herbertdai/7260563 to your computer and use it in GitHub Desktop.
Save herbertdai/7260563 to your computer and use it in GitHub Desktop.
convert byte to int in Big endian mode
public static int byteToInt(byte[] b,int start) {
int s = 0;
int s0 = b[start] & 0xff;// 最低位
int s1 = b[start+1] & 0xff;
int s2 = b[start+2] & 0xff;
int s3 = b[start+3] & 0xff;
s3 <<= 24;
s2 <<= 16;
s1 <<= 8;
s = s0 | s1 | s2 | s3;
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment