Java Byte Array to Endian BytesToDouble_With_Little_Endian(byte[] bytes)

Here you can find the source of BytesToDouble_With_Little_Endian(byte[] bytes)

Description

Bytes To Doubl Wit Littl Endian

License

Open Source License

Declaration

public static double BytesToDouble_With_Little_Endian(byte[] bytes) 

Method Source Code

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

public class Main {
    public static double BytesToDouble_With_Little_Endian(byte[] bytes) {
        if (bytes == null || bytes.length != 8) {
            return 0;
        }/*from  w  w  w .j a  v  a  2  s  .co m*/

        long tmp = 0;
        for (int i = 0; i < 8; i++) {
            tmp = (tmp << 8) | (bytes[i] & 0xFF);
        }

        return Double.longBitsToDouble(tmp);
    }
}

Related

  1. bytesToInt(byte[] bytes, int offset, int length, boolean littleEndian)
  2. bytesToInt32(byte[] buffer, int byteOffset, boolean bigEndian)
  3. bytesToIntBigEndian(byte[] buf)
  4. bytesToIntLE(byte[] bytes, int offset, int length)