Here you can find the source of bcdToLong(byte[] src, int flag)
public static long bcdToLong(byte[] src, int flag)
//package com.java2s; //License from project: Apache License public class Main { public static long bcdToLong(byte[] src, int flag) { byte high, low; long re = 0; if (flag == 0) { for (int i = 0; i < src.length; i++) { re *= 256;/*from w ww . ja v a 2 s .co m*/ high = (byte) (src[i] >> 4 & 0x0f); low = (byte) (src[i] & 0x0f); re += Long.valueOf(high) * 16 + Long.valueOf(low); } } else { for (int i = 0; i < src.length; i++) { re *= 100; high = (byte) (src[i] >> 4 & 0x0f); low = (byte) (src[i] & 0x0f); re += Long.valueOf(high) * 10 + Long.valueOf(low); } } return re; } }