Java Utililty Methods Integer Create

List of utility methods to do Integer Create

Description

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

Method

inttoInt(byte value)
Interpret the byte value as unsigned.
return value & 0xFF;
inttoInt(byte... b)
to Int
return (int) toLong(b);
inttoInt(byte... b)
to Int
return (int) toLong(b);
inttoInt(byte[] b)
to Int
return toInt(b, 0);
inttoInt(byte[] b)
to Int
int MASK = 0xFF;
int result = 0;
result = b[3] & MASK;
result = result + ((b[2] & MASK) << 8);
result = result + ((b[1] & MASK) << 16);
result = result + ((b[0] & MASK) << 24);
return result;
inttoInt(byte[] b)
to Int
return (((((int) b[3]) & 0xFF)) | ((((int) b[2]) & 0xFF) << 8) | ((((int) b[1]) & 0xFF) << 16)
        | ((((int) b[0]) & 0xFF) << 24));
inttoInt(byte[] b)
to Int
assert (b.length == LENGTH_SIZE);
int n = 0;
n |= ((b[0] & 0x000000FF) << 3 * 8);
n |= ((b[1] & 0x000000FF) << 2 * 8);
n |= ((b[2] & 0x000000FF) << 1 * 8);
n |= (b[3] & 0x000000FF);
return n;
inttoInt(byte[] b)
to Int
int value = 0;
for (int x = 0; x < b.length; x++) {
    value |= b[x] & 0xFF;
    if (x != b.length - 1) {
        value <<= 8;
return value;
...
inttoInt(byte[] b)
Converts the first four bytes of b to a 32-bit signed integer.
return toInt(b, 0);
inttoInt(byte[] b)
Converts a byte array of 1-4 bytes to an int.
if ((b.length < 1) || (b.length > 4)) {
    throw new IllegalArgumentException("Array of size " + b.length + " cannot be converted to int.");
int result = 0;
for (int i = 0; i < b.length; i++) {
    result = ((0xFF & b[i]) << ((b.length - i - 1) * 8)) | result;
return result;
...