/** * Created by Lovell on 7/7/16. */ public class UnsignedUtil { /** * java byte (1 byte == 8 bit) (-2^7~2^7-1 : -128~127) to unsigned short(0~2^8-1 : 0~255) * * @param data * @return */ public static int getUnsignedByte (byte data){ return data&0x0FF; } /** * java short (1 short == 2 byte == 16 bit) (-2^15~2^15-1 : -32768~32767) to unsigned short(0~2^16-1 : 0~65535) * * @param data * @return */ public static int getUnsignedShort (short data){ return data&0x0FFFF; } /** * java int (1 int == 4 byte == 32 bit)(-2^31~2^31-1 : -2147483648~2147483647) to unsigned short(0~2^32-1 : 0~4294967295) * * @param data * @return */ public long getUnsignedInt (int data){ return data&0x0FFFFFFFF; } }
在项目要使用无符号整型,可以在项目中加入joou.jar ,用法如下
joou官网: http://www.jooq.org
google code主页:http://code.google.com/p/joou/
原文:https://www.cnblogs.com/QuickSlow/p/14049634.html