Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static double calculateHalfByteBCDFromByteArrayAtBaseTen(byte[] b) {
        int power = 0;
        double result = 0.0;
        for (int i = b.length - 1; i >= 0; i--) {
            byte last = b[i];
            double l = (int) (last & 0x0F) * 0.1 * Math.pow(10, power);
            double l2 = (int) (last & 0xF0) * 0.1 * Math.pow(10, power + 1);
            result += l2 + l;
            power = power + 2;
        }
        return result;
    }
}