List of utility methods to do Unsigned Number Create
long | unsigned(int num) unsigned return 0xFFFFFFFFL & num;
|
long | unsigned(int val) Considers the bits of a signed 32-bit integer, and converts it into a long integer as if it were unsigned, i.e. return val >= 0 ? val : ((val & 0x7FFFFFFF) | (1L << 31)); |
int | unsigned(short value) Convert a short into its unsigned representation as int. return value & 0x0000ffff;
|
long | unsigned16(short s) unsigned return s & 0xFFFFL;
|
byte[] | unsigned32ToBytes(long value) unsigned To Bytes return toBytes(value, 4);
|
long | unsigned32ToInt(byte[] bytes) unsigned To Int return fromBytes(bytes, 4);
|
long | unsigned4BytesToInt(byte[] buf, int pos) unsigned Bytes To Int int firstByte = 0; int secondByte = 0; int thirdByte = 0; int fourthByte = 0; int index = pos; firstByte = (0x000000FF & ((int) buf[index])); secondByte = (0x000000FF & ((int) buf[index + 1])); thirdByte = (0x000000FF & ((int) buf[index + 2])); ... |
int | unsigned8(byte b) unsigned return b & 0xFF;
|
int | unsigned_byte(byte b) unsignebyte return b & 0xff;
|
boolean | unsignedAddOverflow(int operand1, int operand2) Returns true, if the addition of both operands as unsigned integers will cause an overflow. long value1 = (long) operand1 & 0xFFFFFFFFL; long value2 = (long) operand2 & 0xFFFFFFFFL; return ((value1 + value2) & 0x100000000L) != 0; |