- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
const char *byte2binstr(unsigned char byte) {
#define AA BB(0), BB(1)
#define BB(b0) CC(b0, 0), CC(b0, 1)
#define CC(b0, b1) DD(b0, b1, 0), DD(b0, b1, 1)
#define DD(b0, b1, b2) EE(b0, b1, b2, 0), EE(b0, b1, b2, 1)
#define EE(b0, b1, b2, b3) FF(b0, b1, b2, b3, 0), FF(b0, b1, b2, b3, 1)
#define FF(b0, b1, b2, b3, b4) GG(b0, b1, b2, b3, b4, 0), GG(b0, b1, b2, b3, b4, 1)
#define GG(b0, b1, b2, b3, b4, b5) HH(b0, b1, b2, b3, b4, b5, 0), HH(b0, b1, b2, b3, b4, b5, 1)
#define HH(b0, b1, b2, b3, b4, b5, b6) II(b0, b1, b2, b3, b4, b5, b6, 0), II(b0, b1, b2, b3, b4, b5, b6, 1)
#define II(b0, b1, b2, b3, b4, b5, b6, b7) STR(b0 ## b1 ## b2 ## b3 ## b4 ## b5 ## b6 ## b7)
#define STR(s) #s
static const char *table[256] = { AA };
return table[byte];
#undef AA
#undef BB
#undef CC
#undef DD
#undef EE
#undef FF
#undef GG
#undef HH
#undef II
#undef STR
}
Antervis 15.01.2016 07:53 # +3
imihajlov 15.01.2016 12:14 # +5
bormand 15.01.2016 17:44 # 0
imihajlov 15.01.2016 18:23 # 0
bormand 15.01.2016 19:05 # 0