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

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

Description

bytesdouble

License

Apache License

Declaration

public static double bytes2double(byte[] bytes) 

Method Source Code

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

public class Main {
    public static double bytes2double(byte[] bytes) {
        long l = bytes2long(bytes);
        return Double.longBitsToDouble(l);
    }/* ww w  .  j  av a2  s  . c om*/

    public static double bytes2double(byte[] bytes, int offset) {
        long l = bytes2long(bytes, offset);
        return Double.longBitsToDouble(l);
    }

    public static long bytes2long(byte[] bytes) {
        long num = 0;
        for (int i = 0; i < 8; i++) {
            num <<= 8;
            num |= (bytes[i] & 0xff);
        }
        return num;
    }

    public static long bytes2long(byte[] bytes, int offset) {
        long num = 0;
        for (int i = offset; i < offset + 8; i++) {
            num <<= 8;
            num |= (bytes[i] & 0xff);
        }
        return num;
    }
}

Related

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