List of utility methods to do Long to
void | long2Arr(long var, byte[] arrayBytes, int startIndex) Write the bytes of "var" into new byte array. int length = 8; if (arrayBytes != null && startIndex + length <= arrayBytes.length) { for (int j = startIndex; j < startIndex + length; j++) { arrayBytes[j] = (byte) var; var >>= 8; |
long[][] | long2array(int sz, long seed) longarray long[][] ret = new long[sz][sz]; init(ret, seed); return ret; |
byte[] | long2buff(long n) long convert to buff (big-endian) byte[] bs; bs = new byte[8]; bs[0] = (byte) ((n >> 56) & 0xFF); bs[1] = (byte) ((n >> 48) & 0xFF); bs[2] = (byte) ((n >> 40) & 0xFF); bs[3] = (byte) ((n >> 32) & 0xFF); bs[4] = (byte) ((n >> 24) & 0xFF); bs[5] = (byte) ((n >> 16) & 0xFF); ... |
char[] | long2char(long x) longchar char[] c = new char[4]; c[0] = (char) (x >> 48); c[1] = (char) (x >> 32); c[2] = (char) (x >> 16); c[3] = (char) (x); return c; |
String | long2Date(Long date, String interval) long Date String line = String.valueOf(date); if (line.length() != 8) { return null; } else { StringBuffer buf = new StringBuffer(10); buf.append(line.substring(0, 4)); buf.append(interval); buf.append(line.subSequence(4, 6)); ... |
String | long2dotted(long address) longdotted StringBuilder sb = new StringBuilder(); for (int i = 0, shift = 24; i < 4; i++, shift -= 8) { long value = (address >> shift) & 0xff; sb.append(value); if (i != 3) { sb.append('.'); return sb.toString(); |
char[] | long2FourChars(long i) Converts a long to a char array of four elements char[] asChars = new char[4]; asChars[0] = (char) (i >>> 48); asChars[1] = (char) ((i >>> 32) & 0xFFFF); asChars[2] = (char) ((i >>> 16) & 0xFFFF); asChars[3] = (char) (i & 0xFFFF); return asChars; |
int | Long2H(final long l) Generates an integer hashcode from a long value. return (int) (l ^ (l >>> 32)); |
void | long2leb(final long x, final byte[] buf, final int offset) longleb buf[offset] = (byte) x; buf[offset + 1] = (byte) (x >> 8); buf[offset + 2] = (byte) (x >> 16); buf[offset + 3] = (byte) (x >> 24); buf[offset + 4] = (byte) (x >> 32); buf[offset + 5] = (byte) (x >> 40); buf[offset + 6] = (byte) (x >> 48); buf[offset + 7] = (byte) (x >> 56); ... |
long[] | long2longArr(long val, long[] res) longlong Arr if (res.length == 1) { res[0] = val & 0xFFFFFFFFL; } else if (res.length > 1) { res[res.length - 2] = (val >> 32) & 0xFFFFFFFFL; res[res.length - 1] = val & 0xFFFFFFFFL; for (int i = 0; i < res.length - 2; i++) { res[i] = 0; return res; |