Java Double Number Create toDouble(byte[] data)

Here you can find the source of toDouble(byte[] data)

Description

to Double

License

Apache License

Declaration

public static double toDouble(byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double toDouble(byte[] data) {
        if (data.length != 8)
            return 0;
        return Double.longBitsToDouble(toLong(data));
    }//from   w  w  w .  j a  v  a  2  s .c  o  m

    public static long toLong(byte[] data) {
        if (data.length != 8)
            return 0;
        return (long) data[0] << 56 | (long) data[1] << 48 | (long) data[2] << 40 | (long) data[3] << 32
                | (int) data[4] << 24 | (int) data[5] << 16 | (int) data[6] << 8 | (int) data[7];
    }
}

Related

  1. toDouble(byte[] bytes)
  2. toDouble(byte[] bytes, int index)
  3. toDouble(byte[] bytes, int offset)
  4. toDouble(byte[] data)
  5. toDouble(byte[] data)
  6. toDouble(byte[] data, int offset)
  7. toDouble(byte[] si, boolean isReverseOrder)
  8. toDouble(byte[] value)
  9. toDouble(final byte[] array, final int offset, final int length)