Android Byte Array to Long Convert parseLong(byte[] array, int offset, long[] result)

Here you can find the source of parseLong(byte[] array, int offset, long[] result)

Description

parse Long

License

Open Source License

Declaration

public static long[] parseLong(byte[] array, int offset, long[] result) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static long[] parseLong(byte[] array, int offset, long[] result) {
        return parseLong(array, offset, 0, result);
    }// ww w  .  j  ava2  s  . c o m

    public static long[] parseLong(byte[] array, int offset,
            int multiplier, long[] result) {
        result[0] = 0;

        boolean decimal = false;
        int i, m = multiplier;
        for (i = offset; i < array.length; i++) {
            final byte digit = array[i];
            if (digit == '.') {
                decimal = true;
            } else if ((digit < '0' || digit > '9') || (decimal && m == 0)) {
                break;
            } else {
                result[0] *= 10;
                result[0] += array[i] - '0';
                if (decimal) {
                    m--;
                }
            }
        }
        for (int j = 0; j < m; j++) {
            result[0] *= 10;
        }
        result[1] = i;
        return result;
    }
}

Related

  1. uint16ToLong(byte[] buf, int offset)
  2. uint32ToLong(byte[] buf, int offset)
  3. uint64ToLong(byte[] buf, int offset)
  4. byteArray2long(final byte[] number, final boolean swapHalfWord)
  5. parseLong(byte[] array, int offset, int multiplier, long[] result)
  6. readLong(byte[] buff, int pos)