Java Utililty Methods Array to Long

List of utility methods to do Array to Long

  1. HOME
  2. Java
  3. A
  4. Array to Long

Description

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

Method

long arrayToLong(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];
...
long arrayToLong(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;
...
String arrayToLongString(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("]");
...

AltStyle によって変換されたページ (->オリジナル) /