Java Array Convert to arrayToDouble(final byte[] array, final int start)

Here you can find the source of arrayToDouble(final byte[] array, final int start)

Description

Convert the contents of the specified array to a double, starting at an offset of start.

License

Open Source License

Parameter

Parameter Description
array a parameter
start a parameter

Return

double

Declaration


public static double arrayToDouble(final byte[] array, final int start) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

public class Main {
    private static final int MASK_FF = 0xff;

    /***********************************************************************************************
     * Convert the contents of the specified array to a <code><b>double</b></code>,
     * starting at an offset of <code>start</code>.
     *//w ww.ja v a 2  s.co m
     * @param array
     * @param start
     *
     * @return double
     */

    public static double arrayToDouble(final byte[] array, final int start) {
        int i;
        int count;
        long accum;
        final int length;
        final byte[] temp;

        count = 0;
        length = 8;
        temp = new byte[length];

        for (i = start; i < (start + length); i++) {
            temp[count] = array[i];
            count++;
        }

        accum = 0;
        i = 0;

        for (int shiftBy = 0; shiftBy < Double.SIZE; shiftBy += 8) {
            accum |= ((long) (temp[i] & MASK_FF)) << shiftBy;
            i++;
        }

        return (Double.longBitsToDouble(accum));
    }
}

Related

  1. arrayOfDoubleToString(double[] array)
  2. arrayOfIntToString(int[] array)
  3. arrayOfValuesToLookForIsEmpty()
  4. arrayToCamelCase(String[] nameArray, int start, int end)
  5. arrayToCSL(String[] vals)
  6. arrayToHTMLString(Object[] objectArray, int indent)
  7. arrayToInt(final byte[] array, final int start)
  8. arrayToJava(double[] v, int off, int len, String name)
  9. arrayToJson(int[] x)