cpubbs 发表于 2004-11-6 03:27:08

一种在C51中写二进制的方法

#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) \
)

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

void main(void)
{
unisigned char c;

c = Bin(10101001);// then c = 0xA9
}
页: [1]
查看完整版本: 一种在C51中写二进制的方法