Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static int byte2Int(byte b) {
        int ii = 0;
        int temp = 0x01;

        if (b >= 0)
            return (int) b;

        for (int i = 0; i < 8; i++) {
            if ((b & (temp << i)) != 0) {
                ii += Math.pow(2, i);
            }
        }
        return ii;
    }
}