Java Utililty Methods Unsigned Number Create

List of utility methods to do Unsigned Number Create

Description

The list of methods to do Unsigned Number Create are organized into topic(s).

Method

byte[]unsignedLongToByteArray(final long value)
unsigned Long To Byte Array
if (0 == value)
    return _byte0;
if (0 <= value && value <= 0x00FF) {
    byte[] bb = new byte[1];
    bb[0] = (byte) (value & 0x00FF);
    return bb;
byte[] out = null;
...
StringunsignedLongToString(long value)
Treats the provided long as unsigned and converts it to a string.
if (value >= 0) {
    return Long.toString(value);
} else {
    int max_dig = 20;
    char[] cbuf = new char[max_dig];
    int radix = 10;
    int dst = max_dig;
    long top = value >>> 32;
...
StringunsignedLongToString(long x)
Returns a string representation of x, where x is treated as unsigned.
return unsignedLongToString(x, 10);
byte[]unsignedMediumToBytes(final Long unsignedInt)
Converts unsigned integer to a 3 byte array of unsigned bytes
byte[] bytes = new byte[3];
bytes[2] = (byte) (unsignedInt & 0xFF);
bytes[1] = (byte) ((unsignedInt >> 8) & 0xFF);
bytes[0] = (byte) ((unsignedInt >> 16) & 0xFF);
return bytes;
byte[]unsignedNumericToByteArray(long src, int length)
unsigned Numeric To Byte Array
byte[] result = new byte[length];
for (int i = 0; i < length; i++) {
    result[i] = (byte) (src >>> (length - 1 - i) * 8 & 0xff);
return result;
intunsignedOneSidedGallopingIntersect2by2(final short[] smallSet, final int smallLength, final short[] largeSet, final int largeLength, final short[] buffer)
unsigned One Sided Galloping Intersectby
if (0 == smallLength) {
    return 0;
int k1 = 0;
int k2 = 0;
int pos = 0;
short s1 = largeSet[k1];
short s2 = smallSet[k2];
...
shortunsignedShort(byte b)
Get the specified byte's value as an unsigned short.
return (short) (0x00ff & b);
intunsignedShort(short s)
unsigned Short
byte[] array = shortToByteArray(s);
int b1 = (0x000000FF & ((int) array[0]));
int b2 = (0x000000FF & ((int) array[1]));
return (b1 << 8 | b2);
voidunsignedShort2Arr(int var, byte[] arrayBytes, int startIndex)
Write the bytes of "var" into new byte array.
int length = 2;
if (arrayBytes != null && startIndex + length <= arrayBytes.length) {
    for (int j = startIndex; j < startIndex + length; j++) {
        arrayBytes[j] = (byte) var; 
        var >>= 8;
intunsignedShortAt(byte[] data, int pos)
Returns the unsigned short that starts at the given position in the given byte array.
return ((data[pos + 0] & 0xff) << 8) | ((data[pos + 1] & 0xff) << 0);