Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static float getFloat(float data, byte[] packet, int index) {
        return (Float.intBitsToFloat(getInt(packet, index)));
    }

    public static int getInt(byte[] packet, int index) {

        int result = 0;
        result |= ((packet[index] & (int) 0xFF));
        result |= ((packet[index + 1] & (int) 0xFF) << 8);
        result |= ((packet[index + 2] & (int) 0xFF) << 16);
        result |= ((packet[index + 3] & (int) 0xFF) << 24);

        return result;
    }
}