Java Double Number Create toDouble(byte[] value)

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

Description

to Double

License

Open Source License

Declaration

public static double toDouble(byte[] value) 

Method Source Code

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

public class Main {
    public static double toDouble(byte[] value) {
        long longValue = toLong(value);
        double result = Double.longBitsToDouble(longValue);
        return result;
    }/* ww w  .  ja v  a  2s. c  o m*/

    public static long toLong(byte[] value) {
        return toLong(value, 0);
    }

    /**
     * byte[] -> long
     * 
     * @param value
     * @param offset
     * @return
     */
    public static long toLong(byte[] value, int offset) {
        long result = 0L;
        result = result | (value[7] & 0xff);
        result = result | (((long) value[offset + 6] & 0xff) << 8);
        result = result | (((long) value[offset + 5] & 0xff) << 16);
        result = result | (((long) value[offset + 4] & 0xff) << 24);
        result = result | (((long) value[offset + 3] & 0xff) << 32);
        result = result | (((long) value[offset + 2] & 0xff) << 40);
        result = result | (((long) value[offset + 1] & 0xff) << 48);
        result = result | (((long) value[offset + 0] & 0xff) << 56);
        return result;
    }
}

Related

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