UPDATED 08/29/2010 5:56PM

Added source to the actual repo for the new version of FakeBitOps.

http://adorablebin.googlecode.com/svn/trunk

Check that out and quit worrying about getting updates here. If and when I get the module done, it’ll go under that repo.

This used to be in the Garrysmod.org section. But I have moved it here and deleted the content of the old thread and posted the link to this thread there.

Hey guys, I’m hacking together some stuff that requires bitwise operations, so I made a pure lua library for dealing with binary and hex data. It’s emulated binary operations, so all of it is done through string manipulation.

I’ve lurked here for awhile and figured it could be useful to some of you, so I’m posting it here.

License is BSD. I’d be happy if some of you could contribute. Just ask to join the google code and I’ll accept. Even if you’re just going in there to clean or document.

Hope you find it useful.

Almost the entire library is documented here:

Binary Operations Available:

NOT

XOR

OR

AND

Zero Padding Left

Zero Padding Right

Left Rotate With Carry Over

Right Rotate With Carry Over

Left Rotate Without Carry Over

Right Rotate Without Carry Over

Binary to Hex

Hex Operations Available:

NOT

XOR

OR

AND

Bitwise Zero Padding Left (specify 64 as length and FF will become 00000000000000FF)

Bitwise Zero Padding Right (specify 64 as length and FF will become FF00000000000000)

Left Bitwise Rotate With Carry Over

Right Bitwise Rotate With Carry Over

Left Bitwise Rotate Without Carry Over

Right Bitwise Rotate Without Carry Over

Hex to Binary

Number Operations Available:

Number to hex

Number to binary

String Operations Available:

String to binary

String to hex

There is zero error handling at the moment, so try and keep your string lengths divisible by 8 for binary, divisible by 2 for hex.

Let me know what you think or if you want to join up.

Follow me on twitter, @adorablepuppy