Java Utililty Methods Long Number Convert To

List of utility methods to do Long Number Convert To

Description

The list of methods to do Long Number Convert To are organized into topic(s).

Method

byte[]convertLongToBytes(final long unsignedIntIp)
convert Long To Bytes
byte[] bytes = new byte[4];
bytes[0] = (byte) ((unsignedIntIp & 0xFF000000L) >>> 24);
bytes[1] = (byte) ((unsignedIntIp & 0x00FF0000L) >> 16);
bytes[2] = (byte) ((unsignedIntIp & 0x0000FF00L) >> 8);
bytes[3] = (byte) (unsignedIntIp & 0x000000FFL);
return bytes;
byte[]convertLongToBytes(long l)
convert Long To Bytes
byte[] b = new byte[8];
for (int i = 0; i < 8; i++) {
    b[i] = (byte) (l >>> (56 - (i * 8)));
return b;
StringconvertLongToCharSmall(long theLong)
this method takes a long (less than 36) and converts it to a 1 character string (A-Z, 0-9)
if ((theLong < 0) || (theLong >= 36)) {
    throw new RuntimeException("convertLongToCharSmall() " + " invalid input (not >=0 && <36: " + theLong);
} else if (theLong < 26) {
    return "" + (char) ('A' + theLong);
} else {
    return "" + (char) ('0' + (theLong - 26));
intconvertLongToCidr(long unsignedIntCidr)
convert Long To Cidr
for (int i = 32; i >= 0; i--) {
    if ((unsignedIntCidr & 0x00000001) == 1)
        return i;
    unsignedIntCidr >>>= 1;
return 0;
double[]convertLongToDouble(final long[] longs)
convert Long To Double
final double[] doubles = new double[longs.length];
for (int i = 0; i < longs.length; i++) {
    doubles[i] = Double.longBitsToDouble(longs[i]);
return doubles;
intconvertLongToInt(long l)
Convert a long value to an int value.
if (l <= Integer.MIN_VALUE) {
    return Integer.MIN_VALUE;
} else if (l >= Integer.MAX_VALUE) {
    return Integer.MAX_VALUE;
} else {
    return (int) l;
StringconvertLongToString(long value)
convert Long To String
return Long.toString(value);
intfromLong(long d)

fromLong

if (d == 0L)
    return 0;
double d2 = Math.signum(d) * Math.abs(d) / (1L + Math.abs(d));
int d3 = (int) Math.round(Integer.MAX_VALUE * d2);
return d3;
byte[]fromLong(long input)
Returns a byte array containing 8 network byte-ordered bytes representing the given long .
byte[] output = new byte[8];
output[0] = (byte) (input >> 56);
output[1] = (byte) (input >> 48);
output[2] = (byte) (input >> 40);
output[3] = (byte) (input >> 32);
output[4] = (byte) (input >> 24);
output[5] = (byte) (input >> 16);
output[6] = (byte) (input >> 8);
...
byte[]fromLong(long key)
from Long
byte[] writeBuffer = new byte[8];
writeBuffer[0] = (byte) (key >>> 56);
writeBuffer[1] = (byte) (key >>> 48);
writeBuffer[2] = (byte) (key >>> 40);
writeBuffer[3] = (byte) (key >>> 32);
writeBuffer[4] = (byte) (key >>> 24);
writeBuffer[5] = (byte) (key >>> 16);
writeBuffer[6] = (byte) (key >>> 8);
...