calcbits
calcbits
is a Rust library for bit-level calculations and analysis.
It provides simple and efficient utilities to manipulate, inspect, and compute values at the bit level.
✨ Features
- Count the number of set/unset bits in integers.
- Perform bitwise operations with convenience functions.
- Convert between binary/hexadecimal/string forms.
- Useful for algorithms, cryptography experiments, compression, and systems programming.
📦 Installation
Add calcbits
to your project with Cargo:
[]
= "0.1.0"
Then import it in your code:
use bits;
🚀 Examples
use bits;
📖 API Overview
count_ones(x)
→ number of set bits inx
count_zeros(x)
→ number of unset bits inx
to_binary_string(x, width)
→ binary representation padded towidth
mask(x, mask)
→ apply a mask- More functions coming soon!
🛠 Development
Clone the repo and run tests:
📜 License
Licensed under either of:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
Made with ❤️ in Rust.