BitCore is a lightweight, high-performance C# library for bit manipulation and tuple conversions, optimized for real-time applications like Unity3D. It offers extension methods for packing and unpacking numeric types (byte, sbyte, short, ushort, int, uint, long, ulong) and utilities for bit operations and binary string parsing.
- Bit-level operations (e.g.,
SetBitAt,PopCount,BitString). - Tuple packing/unpacking (e.g.,
PackToInt,UnpackToBytes) in big-endian order. - Aggressive inlining for .NET 4.6+ builds.
- Unity3D-ready with no external dependencies.
- Open Unity, go to
Window > Package Manager. - Click
+>Add package from git URL. - Enter:
https://github.com/astrum-forge/bit-core.git. - Click
Add.
using BitCore;
int value = 0b00001010; // 10
value = value.SetBitAt(2); // 0b00001110 (14)
int bitCount = value.PopCount(); // 3using BitCore;
(byte, byte, byte, byte) bytes = (0x12, 0x34, 0x56, 0x78);
int packed = bytes.PackToInt(); // 0x12345678
var unpacked = packed.UnpackToBytes(); // (0x12, 0x34, 0x56, 0x78)Licensed under the Apache 2.0 License. See the LICENSE file for details.
Fork, branch, and submit a Pull Request with your changes. Keep it fast, simple, and well-documented.