#include <stdio.h> #include <stdlib.h> #define uchar unsigned char uchar BCD_Decimal(uchar bcd) ; int main(void) { uchar ch = 0x20 ; uchar dec = BCD_Decimal(ch) ; printf("dec = %d\n",dec); while(1){ ; } return 0 ; } //BCD码转十进制函数,输入BCD,返回十进制 uchar BCD_Decimal(uchar bcd) { uchar Decimal; Decimal=bcd>>4; return(Decimal=Decimal*10+(bcd&=0x0F)); }
运行结果:20
时间: 2024-12-26 21:33:54