I work with registers a bit, and data sheets that turn everything into bit indices. Luckily, I'm using gcc, which has the binary literal extension syntax so that i can do things like
register |= 0b01000010;
The other option is of course to just use hex format
register |= 0x42;
Despite having worked with hex a bit over time, I still find binary format better for this kind of bit banging. I still decompose the 4 and 2 nibbles into their 0100 and 0010 patterns. So I think the binary format visualizes better. The problem with the binary format though, is that it's hard to find the boundaries. Using hex format, the nibbles separate nicely and so you can "index" bits safer sometimes. IOW, in the top I have to worry I didn't add or omit an extra 0 and end up with bit 7 on instead of 6.
I'm curious if others have developed a technique/trick to have their cake and eat it too. When you have to string constants adjacent in C
"Hello " "World"
The compiler is smart enough to just mash them together into one literal. It would be nice if there was a way to do something similar with these binary numbers, e.g.
0b0100 0010
I could do something weird with macros, perhaps
#define _(a, b) (((a) << 4) | (b))
and then be able to do
_(0b0100,0b0010)
but that's honestly worse, and limited to a pair of nibbles. Curious if someone's come up with something clever and nice.