Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static double getDouble(byte[] bytes) {
        long l = getLong(bytes);
        System.out.println(l);
        return Double.longBitsToDouble(l);
    }

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

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