Aug 10
17
BitVector64 C# Source Code
Ok, so I wrote about a nifty little structure I found within the .NET framework and in doing some searching found that a BitVector64 didn’t exist anywhere. So being bored, and figuring it would only take me a couple hours, I went ahead and did an implementation of a 64-bit version of the BitVector32 structure. Mine will allow you to set a 64 bit value, and find the bit value for all 64 bits, as well as use a (ushort) Section bit mask if you really want to (not sure why) So here it is, source code included… I’m sure there’s something wrong with it, but I know the bit checking works flawlessly!
Please feel free to leave feedback if you find this code useful. Perhaps Microsoft will include it in their next C# release!
Download Here: BitVector64.zip
Code Version: 0.2
Changes since 0.1:
- Changed UInt64 to ulong data types.
- Fixed bug in public ulong this[BitVector64.Section section]. Thanks Saso!
- Cleaned up code using C# StyleCop.
- Added comments where necessary.
Example:
using RobKennedy.BitVectors; ... // Simplest Test of BitVector64 BitVector64 newVec = new BitVector64(Convert.ToInt64(someValue)); // check to see if bit 32 is set (33rd bit if counting from 1) if (newVec[32]) MessageBox.Show("We are bigger than a dword because bit 32 is on!"); ...
