Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int ByteIntValue(byte b) {
        int toReturn = 0;
        for (int i = 0; i < 8; i++) {
            if (GetBit(b, 0)) {
                toReturn += Math.pow(2, i);
            }
        }
        return toReturn;
    }

    private static boolean GetBit(byte b, int bitNumber) //0 es el menos significativo 7 el mas significativo
    {
        return (b & (1 << bitNumber)) != 0;
    }
}