新闻中心

EEPW首页>嵌入式系统>设计应用> 51单片机二进制转换

51单片机二进制转换

作者: 时间:2016-11-13 来源:网络 收藏
#include

#define LongToBin(n)
(
((n >> 21) & 0x80) |
((n >> 18) & 0x40) |
((n >> 15) & 0x20) |
((n >> 12) & 0x10) |
((n >> 9) & 0x08) |
((n >> 6) & 0x04) |
((n >> 3) & 0x02) |
((n ) & 0x01)
)

本文引用地址: //m.amcfsurvey.com/article/201611/316332.htm

#define Bin(n) LongToBin(0x##n##l)

void main(void)
{
unsigned char c;

c = Bin(10101001); // c = 0xA9
}



评论


技术专区

关闭