BCD码与十进制转换

来源:互联网 发布:网络质量监控 编辑:程序博客网 时间:2024/06/05 19:11

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);
0 0
原创粉丝点击