Last active
December 27, 2015 03:38
-
-
Save herbertdai/7260563 to your computer and use it in GitHub Desktop.
convert byte to int in Big endian mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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