///
/// BCD转字符串
///
///
/// 偏移量
/// 数字字符串位数
///
///
public static string BCDToString(byte[] bcdNum, int offset, int numlen)
{
string retString = "";
int res;
var len = Math.DivRem(numlen, 2, out res);
if (res != 0)
{
len++;
}
for (int i = 0; i < len; i++)
{
retString += ((bcdNum[i + offset] & 0xf0) >> 4).ToString("x");
retString += (bcdNum[i + offset] & 0xf).ToString("x");
}
return retString.ToLower().Replace("f", "");
}
标签:BCD,res,len,retString,int,offset,字符串
From: https://www.cnblogs.com/qiutian-hao/p/18082418