2

There are many known bit twiddling hacks, e.g. the list here; as well as numerous questions here on SO.

Is there a standard-ish library, or even a single header file, implementing all of these? (I would get, as inline functions and/or as preprocessor macros.)

Edit: I'm not interested in implementations using specialized types, i.e. bit vectors or bit sets, but rather code which works directly on your ints/unsigneds/etc.

Community
  • 1
  • 1
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • @DavidHeffernan: I didn't ask for a recommendation, merely for references. – einpoklum Jul 08 '13 at 12:32
  • Not that I know of. There's a ton of them anyway, with endless variations, so it's not even feasible. http://programming.sirrida.de/ has source with a lot in it. – harold Jul 08 '13 at 15:05

2 Answers2

1

Well, there's std <bitset> or even bitmagic

Googling will find even more

MichaelH
  • 380
  • 1
  • 7
1

These are 2 libraries named "Bitfile" library and "Bitarray" library. You can find it at:

http://michael.dipperstein.com/bitlibs/

There is also a single header file which you might find useful at:

http://www.catonmat.net/blog/bit-hacks-header-file/

Nithin Bhaskar
  • 686
  • 1
  • 5
  • 9