• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Dokkio Sidebar (from the makers of PBworks) is a Chrome extension that eliminates the need for endless browser tabs. You can search all your online stuff without any extra effort. And Sidebar was #1 on Product Hunt! Check out what people are saying by clicking here.



Page history last edited by Kenneth Finnegan 14 years, 3 months ago

These macros will let you use binary constants straight in your code.  C normally only allows you to use base 8, 10, and 16.  Base 2 is extreamely useful when you're dealing with individual bits in a bitfield.






#include "binconst.h"


unsigned char bitfield = B8(01010101); // 85

unsigned int bigbitfield = B32(10000000,11111111,10101010,01010101); // 2164238933



If you needed, it would be pretty trivial to create a 64 bit binary macro as well.  I'll leave that as an exercise for the reader.




Comments (0)

You don't have permission to comment on this page.