缥缈-九哥(14131338) 17:20:41
#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
}

缥缈-九哥(14131338) 17:23:19
#define _BIN(a,b,c,d,e,f,g,h) ((a < <7)+(b < <6)+(c < <5)+(d < <4)+(e < <3)+(f < <2)+(g < <1)+(h < <0))

#define _bin _BIN // _bin,_BIN均可

Example:
i = _bin(1,1,1,1, 0,0,0,0); // i=0xF0
i = _bin(1,0,1,0, 1,0,0,1); // i=0xA9