List of utility methods to do Unsigned Number Create
long | unsignedDiv(long l1, long l2) unsigned Div long unsignedRes = 0L; if (l1 >= 0L) { if (l2 >= 0L) unsignedRes = l1 / l2; } else if (l2 >= 0L && (l1 -= (unsignedRes = ((l1 >>> 1) / l2) << 1) * l2) < 0L || l1 >= l2) unsignedRes++; return unsignedRes; |
String | unsignedExtend(String hex) unsigned Extend int numOfMissingHexDigit = SIZE_OF_LONG_HEX - hex.length(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < numOfMissingHexDigit; i++) { sb.append('0'); return sb.append(hex).toString(); |
String | unsignedHalfwordToString(int value) Interprets the lowest 16 bits of the specified value as an unsigned integer number and renders that number as a four-digit hex string. return String.format("%04x", value & 0xffff); |
int | unsignedInt(byte b) Get the specified byte's value as an unsigned integer. return 0x000000ff & b;
|
long | unsignedInt(int i) unsigned Int long l = i; l = l & (0xFFFFFFFFL); return l; |
Integer | unsignedInt(int value) Convert an unsigned 32-bit integer to a string. if (value < 0) { return (int) ((value) & 0x00000000FFFFFFFFL); return value; |
void | unsignedInt2ByteLE(byte[] bytes, long value, int offset) unsigned Int Byte LE checkLength(bytes, 4, offset); bytes[offset + 0] = (byte) ((value & 0xff)); bytes[offset + 1] = (byte) ((value >> 8 * 1) & 0xff); bytes[offset + 2] = (byte) ((value >> 8 * 2) & 0xff); bytes[offset + 3] = (byte) ((value >> 8 * 3)); |
long | unsignedInt2Long(int x) unsigned Int Long return x & 0xFFFFFFFFL;
|
byte[] | unsignedInt32ToBytes(long v) Convert unsigned int 32 bit value in long to the byte array. byte[] ary = new byte[4]; for (int i = 0; i < 4; i++) { ary[i] = (byte) (v & 0xff); v >>= 8; return ary; |
int[] | unsignedIntArray2signedIntArray(int[] myIntArray, int numberOfBytes) unsigned Int Arraysigned Int Array for (int i = 0; i < myIntArray.length; i++) { if (myIntArray[i] >= 2 << (numberOfBytes * 8 - 2)) { myIntArray[i] -= 2 << (numberOfBytes * 8 - 1); return myIntArray; |