https://github.com/arl/bitstring
Go Bitstring module
https://github.com/arl/bitstring
bit-twiddling bitmap bitstring go golang
Last synced: 6 months ago
JSON representation
Go Bitstring module
- Host: GitHub
- URL: https://github.com/arl/bitstring
- Owner: arl
- License: mit
- Created: 2021-05-18T19:44:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-18T23:01:31.000Z (over 4 years ago)
- Last Synced: 2025-03-23T14:42:11.874Z (9 months ago)
- Topics: bit-twiddling, bitmap, bitstring, go, golang
- Language: Go
- Homepage:
- Size: 80.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/arl/bitstring)
[](https://github.com/arl/bitstring/actions)
[](https://goreportcard.com/report/github.com/arl/bitstring)
[](https://codecov.io/gh/arl/bitstring)
# `bitstring`
Go bitstring library
Package `bitstring` implements a fixed length bit string type and bit manipulation functions.
- Get/Set/Clear/Flip a single bit: `Bit`|`SetBit`|`ClearBit`|`FlipBit`
- Set/Clear/Flip a range of bits: `SetRange`|`ClearRange`|`FlipRange`
- Compare 2 bit strings: `Equals` or `EqualsRange`
- 8/16/32/64/N signed/unsigned to/from conversions:
- `Uint8`|`Uint16`|`Uint32`|`Uint64`|`Uintn`
- `SetUint8`|`SetUint16`|`SetUint32`|`SetUint64`|`SetUintn`
- Count ones/zeroes: `ZeroesCount`|`OnesCount`
- Gray code conversion methods: `Gray8`|`Gray16`|`Gray32`|`Gray64`|`Grayn`
- Convert to/from `big.Int`: `BigInt` | `NewFromBig`
- Copy/Clone methods: `Copy`|`Clone`|`CopyRange`
- Trailing/LeadingZeroes : `TrailingZeroes`|`LeadingZeroes`
# Debug version
By default, bit offsets arguments to `bitstring` methods are not checked. This
allows not to pay the performance penalty of always checking offsets, in
environments where they are constants or always known beforehand.
You can enable runtime checks by passing the `bitstring_debug` build tag to `go`
when building the `bitstring` package.
**TODO**:
- RotateLeft/Right ShiftLeft/Right
- Trailing/Leading ones
- Or, And, Xor between bitstrings
- Reverse
- Run CI on big|little endian and 32|64 bits (for now only amd64) (see https://github.com/docker/setup-qemu-action)