We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I just want to code a binary data in C. I mean hera representation is "0x5F", the decimal representation is simply "156" but what is the decimal representation. I tried 0b010010101 but it doesn't work Many thanks Sébastien
#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)
A very elegant macro! Has its limitations, though (max. number of bits). But the idea is great.
Nice idea. By the way <pre> and </pre> need to be lower case.