Java Utililty Methods Array to Long

List of utility methods to do Array to Long

Description

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

Method

longarrayToLong(final byte[] array, final int start)
Convert the contents of the specified array to a long, starting at an offset of start.
int i;
int count;
long accum;
final int length;
final byte[] temp;
count = 0;
length = 4;
temp = new byte[length];
...
longarrayToLong(final int[] digits)
eg: number = { 1, 2, 3, 4 }, returns a long = 1234 if the number correspondent of digits is bigger than Long.MAX_VALUE, so Long.MAX_VALUE is returned.
long result = 0;
long pot = 1;
for (int i = digits.length - 1; i >= 0; i--) {
    long partial = digits[i] * pot;
    if (Long.MAX_VALUE - result - partial > 0) {
        result += partial;
    } else {
        return Long.MAX_VALUE;
...
StringarrayToLongString(T[] array)
array To Long String
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < array.length; i++) {
    sb.append(array[i].toString());
    if (i != array.length - 1)
        sb.append(", ");
sb.append("]");
...