Java Utililty Methods Integer to

List of utility methods to do Integer to

Description

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

Method

byteintToUByte(int i)
int To U Byte
if ((i > 255) || (i < 0))
    throw new RuntimeException("can't convert " + i + " to an unsigned byte");
return (byte) i;
longintToULong(int signed)
int To U Long
if (signed < 0) {
    return ((long) signed) + (((long) Integer.MAX_VALUE) - ((long) Integer.MIN_VALUE) + 1);
return signed;
longintToUnsigned(int signed)
int To Unsigned
if (signed >= 0) {
    return signed;
} else {
    return (long) (4294967296L + (long) signed);
byteintToUnsignedByte(int i)
int To Unsigned Byte
return (byte) ((i <= 0x7F) ? i : i - 0x100);
longintToUnsignedInt(int data)
int to unsigned int
return data & 0xffffffffL;
longintToUnsignedLong(int data)

Converts the given integer value to an unsigned long number.

return 0x00000000ffffffff & ((long) data);
byte[]intToUnsignedShort(int value)
int To Unsigned Short
byte[] ret = new byte[2];
ret[0] = (byte) ((value & 0xff00) >>> 8);
ret[1] = (byte) (value & 0xff);
return ret;
StringintToWeb(int color)
int To Web
int b = (color) & 0xFF;
int g = (color >> 8) & 0xFF;
int r = (color >> 16) & 0xFF;
return hex2d(Integer.toString(r, 16)) + hex2d(Integer.toString(g, 16)) + hex2d(Integer.toString(b, 16));
intintToZigZag(final int n)
int To Zig Zag
return (n << 1) ^ (n >> 31);