https://github.com/lambdacasserole/backspin
Bit flipping/manipulation Maven package for Java.
https://github.com/lambdacasserole/backspin
binary bit-manipulation java maven
Last synced: about 1 month ago
JSON representation
Bit flipping/manipulation Maven package for Java.
- Host: GitHub
- URL: https://github.com/lambdacasserole/backspin
- Owner: lambdacasserole
- License: mit
- Created: 2016-05-17T13:15:16.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-08T09:13:06.000Z (almost 10 years ago)
- Last Synced: 2025-04-06T14:16:28.018Z (about 1 year ago)
- Topics: binary, bit-manipulation, java, maven
- Language: Java
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Backspin
Bit flipping/manipulation Maven package for Java.
When it comes to getting down and dirty with ones and zeroes, it's easy to get lost in a sea of bitwise operators. Backspin is a minimal bit manipulation library that allows you to deal in raw binary digits without ever typing '&' or '|' (unless you want to, of course).
Using this library, you can literally write booleans to a stream to output data bit-by-bit:
```
// Create stream and call both overloads.
BitOutputStream subject = new BitOutputStream();
subject.write(true);
subject.write(BitSequence.fromBitString("000000011111111"));
// Array should be of length 2.
byte[] bytes = subject.toArray();
assertEquals(2, bytes.length);
// First byte should be '10000000' or -128.
assertEquals(-128, bytes[0]);
// Second byte should be '11111111' or -1.
assertEquals(-1, bytes[1]);
```
Perhaps you're writing your own Huffman compression stuff and you need to deal with bit sequences, perhaps you're dealing with an obscure [P4 type portable bitmap file](https://en.wikipedia.org/wiki/Netpbm_format) or maybe you just want to get your binary arithmetic on. Changes are, backspin has what you need.
## Contributing
For most intents and purposes, Backspin is considered to fulfil its original use case. Bug fixes and suggestions are welcome, however, from any member of the community.
## Acknowlegements
This suite of classes was isolated from the [the Denobo codebase](https://github.com/lambdacasserole/denobo) because [James Healey](https://github.com/JamesHealey94) used it like a badass to squeeze simple images into under 1KB when he put together [his app Wisecrack](http://jameshealey.me/). Cheers boi.