BCD码转换成十进制

BCD码转换成十进制

int BCDToInt(byte bcd)
{
      return (0xff & (bcd>>4))*10 +(0xf & bcd);
}


#include<time.h>
main(){
char *wday[]={“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”};
time_t timep;
struct tm *p;
time(&timep);
p=localtime(&timep); /*取得当地时间*/
printf (“%d%d%d ”, (1900+p->tm_year),( l+p->tm_mon), p->tm_mday);
printf(“%s%d:%d:%d\n”, wday[p->tm_wday],p->tm_hour, p->tm_min, p->tm_sec);
}

你可能感兴趣的:(BCD码转换成十进制)