Java Utililty Methods Unsigned Byte Create

List of utility methods to do Unsigned Byte Create

Description

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

Method

inttoUnsignedByte(byte b)
Converts the signed byte to its unsigned integer representation.
return (int) (b & 0xFF);
shorttoUnsignedByte(byte b)
Converts a byte to the corresponding unsigned byte value and returns the result as a short
return (short) (b & MAX_BYTE);
shorttoUnsignedByte(byte b)
Convert a byte to unsigned byte
return Integer.valueOf(b & 0xFF).shortValue();
inttoUnsignedByte(byte b)
This method gets eventually inlined, becoming very fast
return (0x000000FF & b);
shorttoUnsignedByte(byte value)
Return the unsigned byte value [0|255] from the java byte value [-128|127].
return (short) (value - Byte.MIN_VALUE);
inttoUnsignedByte(byte[] buf, int pos)
to Unsigned Byte
int b = buf[pos];
if (b < 0) {
    b = 256 + b;
return b;
shorttoUnsignedByte(char[] bytes, boolean le)
to Unsigned Byte
if (bytes.length != 2)
    return 0;
return (short) Long.parseLong(bytesToString(bytes, le, false), 16);
bytetoUnsignedByte(int value)
Transforms the given integer value to an byte-value representing a number between 0 and 255.
if (value > 255 || value < 0) {
    throw new IllegalArgumentException(
            "Unsigned byte value range is between 0 and 255 - the value [" + value + "] is not valid.");
return (byte) value;
inttoUnsignedByte(int value)
to Unsigned Byte
return value &= UNSIGNED_BYTE_MAX;
int[]toUnsignedByteArray(byte[] b)
to Unsigned Byte Array
int[] r = new int[b.length];
for (int i = 0; i < b.length; i++) {
    r[i] = b[i] + 0x80;
return r;