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 fromBcd(byte b) {//returns an int < 99
        if ((b & 0xFF) > 0x99)
            throw new RuntimeException("Value greater than 99 is not a valid BCD encoded byte");

        int units = b & 0x0F;
        int tens = b >> 4;
        return ((tens * 10) + units);
    }
}