Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lit-technology/bit-ranges
(Un)setting n least significant bits and merging intersecting number ranges.
https://github.com/lit-technology/bit-ranges
bits go
Last synced: 2 months ago
JSON representation
(Un)setting n least significant bits and merging intersecting number ranges.
- Host: GitHub
- URL: https://github.com/lit-technology/bit-ranges
- Owner: lit-technology
- License: mit
- Created: 2019-03-16T07:36:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T11:14:34.000Z (over 4 years ago)
- Last Synced: 2024-08-03T23:27:37.145Z (6 months ago)
- Topics: bits, go
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - bit-ranges
README
# Bit Ranges
[![BuildStatus Widget]][BuildStatus Result]
[![CodeCov Widget]][CodeCov Result]
[![GoReport Widget]][GoReport Status]
[![GoDoc Widget]][GoDoc][BuildStatus Result]: https://travis-ci.org/philip-bui/bit-ranges
[BuildStatus Widget]: https://travis-ci.org/philip-bui/bit-ranges.svg?branch=master[CodeCov Result]: https://codecov.io/gh/philip-bui/bit-ranges
[CodeCov Widget]: https://codecov.io/gh/philip-bui/bit-ranges/branch/master/graph/badge.svg[GoReport Status]: https://goreportcard.com/report/github.com/philip-bui/bit-ranges
[GoReport Widget]: https://goreportcard.com/badge/github.com/philip-bui/bit-ranges[GoDoc]: https://godoc.org/github.com/philip-bui/bit-ranges
[GoDoc Widget]: https://godoc.org/github.com/philip-bui/bit-ranges?status.svgLibrary for setting and unsetting `n` least significant bits as ranges, and merging intersecting ranges.
## Usage
```go
import (
"github.com/philip-bui/bit-ranges"
)func main() {
l, h := bits.RangeUint64(5, 777) // 1100001001.
// l = 768, 1100000000.
// h = 799, 1100011111.
arr := bits.RangesUint64(5, 700, 799, 777, 768, 800, 77)
// arr = [831, 768, 703, 672, 95, 64]. Arr will always be even amount (pairs).
}
```## License
Bit Ranges is available under the MIT license. [See LICENSE](https://github.com/philip-bui/bit-ranges/blob/master/LICENSE) for details.