当前位置:   article > 正文

BCD码与十进制转换_bcdtodec

bcdtodec

BCD码转十进制

#include <stdint.h>

/* convert from BCD to dec */
uint8_t dec  = (bcd  >> 4) * 10 + (bcd  & 0x0f);
  • 1
  • 2
  • 3
  • 4

十进制转BCD码

#include <stdint.h>

/* convert from dec to BCD */
uint8_t bcd = ((dec / 10) << 4 & 0xf0) + ((dec % 10) & 0x0f);
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/258451?site
推荐阅读
相关标签
  

闽ICP备14008679号