赞
踩
BCD码转十进制
#include <stdint.h>
/* convert from BCD to dec */
uint8_t dec = (bcd >> 4) * 10 + (bcd & 0x0f);
十进制转BCD码
#include <stdint.h>
/* convert from dec to BCD */
uint8_t bcd = ((dec / 10) << 4 & 0xf0) + ((dec % 10) & 0x0f);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。