Java Double Number Create toDouble(byte[] bytes)

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

Description

to Double

License

Open Source License

Declaration

public static double toDouble(byte[] bytes) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Shuichi Miura.//www. j  a  v  a  2s .com
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Shuichi Miura - initial API and implementation
 ******************************************************************************/

public class Main {
    public static double toDouble(byte[] bytes) {

        long longValue = toLong(bytes);
        return Double.longBitsToDouble(longValue);
    }

    public static long toLong(byte[] bytes) {

        return ((long) bytes[7] & 255L) + (((long) bytes[6] & 255L) << 8) + (((long) bytes[5] & 255L) << 16)
                + (((long) bytes[4] & 255L) << 24) + (((long) bytes[3] & 255L) << 32)
                + (((long) bytes[2] & 255L) << 40) + (((long) bytes[1] & 255L) << 48)
                + (((long) bytes[0] & 255L) << 56);
    }
}

Related

  1. toDouble(byte[] arr)
  2. toDouble(byte[] b)
  3. toDouble(byte[] byteArray)
  4. toDouble(byte[] bytes)
  5. toDouble(byte[] bytes, int index)
  6. toDouble(byte[] bytes, int offset)
  7. toDouble(byte[] data)