Java Byte Array to Double bytesToDouble(byte[] bytes)

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

Description

bytes To Double

License

Apache License

Declaration

public static double bytesToDouble(byte[] bytes) 

Method Source Code

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

public class Main {
    public static double bytesToDouble(byte[] bytes) {
        long l = bytesToLong(bytes);
        return Double.longBitsToDouble(l);
    }/*from  ww  w.  ja  v a 2  s.co  m*/

    public static long bytesToLong(byte[] bytes) {
        return bytesToLong(bytes, 0);
    }

    public static long bytesToLong(byte[] bytes, int offset) {
        return (0xffL & (long) bytes[offset]) | (0xff00L & ((long) bytes[offset + 1] << 8))
                | (0xff0000L & ((long) bytes[offset + 2] << 16)) | (0xff000000L & ((long) bytes[offset + 3] << 24))
                | (0xff00000000L & ((long) bytes[offset + 4] << 32))
                | (0xff0000000000L & ((long) bytes[offset + 5] << 40))
                | (0xff000000000000L & ((long) bytes[offset + 6] << 48))
                | (0xff00000000000000L & ((long) bytes[offset + 7] << 56));
    }
}

Related

  1. byteArrayToDoubleBE(byte[] data)
  2. bytes2double(byte[] b)
  3. bytes2double(byte[] bytes)
  4. bytesToDouble(byte[] buffer)
  5. bytesToDouble(byte[] bytes)
  6. bytesToDouble(byte[] bytes, int off)
  7. bytesToDouble(byte[] bytes, int offset)
  8. bytesToDouble(byte[] bytes, int startIndex)
  9. bytesToDouble(byte[] data, int[] offset)