Java Utililty Methods Long Number Create

List of utility methods to do Long Number Create

Description

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

Method

longconvertLong(byte[] data, int offset)
This method uses a leading 1 byte[] This method converts a 4 byte integer that is stored in a byte[] and converts it to a decimal int
byte[] target = new byte[4];
System.arraycopy(data, offset, target, 0, target.length);
return convertLong(target);
byte[]convertLong(long v, boolean isLE)
Convert long value to bytes arrays.
byte[] bytes = new byte[8];
if (isLE) {
    bytes[0] = (byte) (v >>> 0);
    bytes[1] = (byte) (v >>> 8);
    bytes[2] = (byte) (v >>> 16);
    bytes[3] = (byte) (v >>> 24);
    bytes[4] = (byte) (v >>> 32);
    bytes[5] = (byte) (v >>> 40);
...
byte[]convertLong2FourBytes(long data)
convert Long Four Bytes
byte[] result = new byte[4];
result[3] = ((byte) (0xFF & data));
result[2] = ((byte) ((0xFF00 & data) >> 8));
result[1] = ((byte) ((0xFF0000 & data) >> 16));
result[0] = ((byte) ((0xFF000000 & data) >> 24));
return result;
byte[]convertLongAddressToBuf(long ipAddress)
convert Long Address To Buf
byte[] result = new byte[4];
result[0] = (byte) ((ipAddress >> 24) & 0xFF);
result[1] = (byte) ((ipAddress >> 16) & 0xFF);
result[2] = (byte) ((ipAddress >> 8) & 0xFF);
result[3] = (byte) ((ipAddress >> 0) & 0xFF);
return result;
Long[]convertLongArray(long[] arr)
convert Long Array
Long[] ret = new Long[arr.length];
for (int i = 0; i < arr.length; i++) {
    ret[i] = arr[i];
return ret;
longconvertLongArrayFromHex(char[] hex)
convert Long Array From Hex
int hexLen = hex.length;
if (hexLen < 16)
    throw new IllegalArgumentException("Too few characters: " + hexLen);
int h = (getHex(hex[0]) << 28) | (getHex(hex[1]) << 24) | (getHex(hex[2]) << 20) | (getHex(hex[3]) << 16)
        | (getHex(hex[4]) << 12) | (getHex(hex[5]) << 8) | (getHex(hex[6]) << 4) | (getHex(hex[7]));
int l = (getHex(hex[8]) << 28) | (getHex(hex[9]) << 24) | (getHex(hex[10]) << 20) | (getHex(hex[11]) << 16)
        | (getHex(hex[12]) << 12) | (getHex(hex[13]) << 8) | (getHex(hex[14]) << 4) | (getHex(hex[15]));
return (((long) h) << 32) | (l & 0xffffffffL);
...
double[]convertLongArrayToDoubleArray(long[] values)
convert Long Array To Double Array
double[] result = new double[values.length];
for (int i = 0; i < result.length; i++) {
    result[i] = values[i];
return result;
longconvertLongFromBytes(byte[] bytes)
convert Long From Bytes
return convertLongFromBytes(bytes, 0);
doubleconvertLongitudeFromMercator(double mercatorLongitude)
convert Longitude From Mercator
return Math.toDegrees(mercatorLongitude) / R_MAJOR;
StringconvertLongPriceToString(long price)
convert Long Price To String
return String.format("%.2f", (double) price / 100);