Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Author(s): Pascal Heus (pheus@opendatafoundation.org)
 *  
 * This product has been developed with the financial and 
 * technical support of the UK Data Archive Data Exchange Tools 
 * project (http://www.data-archive.ac.uk/dext/) and the 
 * Open Data Foundation (http://www.opendatafoundation.org) 
 * 
 * Copyright 2007 University of Essex (http://www.esds.ac.uk) 
 * 
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 * The full text of the license is also available on the Internet at 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 */

public class Main {
    /**
     * Converts a 8-byte value into a double
     * 
     * @param buffer
     * @return converted value as double
     */
    public static double byte8ToDouble(byte[] buffer) {
        long lvalue = (((long) (buffer[7]) << 56) + ((long) (buffer[6] & 0xFF) << 48)
                + ((long) (buffer[5] & 0xFF) << 40) + ((long) (buffer[4] & 0xFF) << 32)
                + ((long) (buffer[3] & 0xFF) << 24) + ((long) (buffer[2] & 0xFF) << 16)
                + ((long) (buffer[1] & 0xFF) << 8) + (long) (buffer[0] & 0xFF));
        return (Double.longBitsToDouble(lvalue));
    }
}