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

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

Description

bytes To Double

License

Open Source License

Declaration

public static double bytesToDouble(byte[] bytes) 

Method Source Code

//package com.java2s;
/*/*from  w w  w  .  ja va2 s .co m*/
 * Copyright 2012 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */

public class Main {

    public static double bytesToDouble(byte[] bytes) {
        long l;
        l = bytes[0];
        l &= 0xff;
        l |= ((long) bytes[1] << 8);
        l &= 0xffff;
        l |= ((long) bytes[2] << 16);
        l &= 0xffffff;
        l |= ((long) bytes[3] << 24);
        l &= 0xffffffffl;
        l |= ((long) bytes[4] << 32);
        l &= 0xffffffffffl;
        l |= ((long) bytes[5] << 40);
        l &= 0xffffffffffffl;
        l |= ((long) bytes[6] << 48);
        l &= 0xffffffffffffffl;
        l |= ((long) bytes[7] << 56);
        return Double.longBitsToDouble(l);
    }
}

Related

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