aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2021-07-20 01:42:01 +0000
committerFelix Hanley <felix@userspace.com.au>2021-07-20 01:42:01 +0000
commit3c49c460275b5c6a20a3105700ccc9cf2ac04db4 (patch)
tree31adc5cd6ce5c42a8751fb0e0bf9c10d2700fd76
parent56ff479697803b0551f2e89c5e9eae7fc4f1a54a (diff)
downloadbitarray-3c49c460275b5c6a20a3105700ccc9cf2ac04db4.tar.gz
bitarray-3c49c460275b5c6a20a3105700ccc9cf2ac04db4.tar.bz2
Update README to explain usage
-rw-r--r--README.md12
1 files changed, 11 insertions, 1 deletions
diff --git a/README.md b/README.md
index 84b8b0d..f6c1236 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,11 @@
# BitArray
This package provides a bit array structure with sub-byte methods like packing
-and shifting for arrays of arbitrary length.
+and shifting for arrays of bits of arbitrary length.
+
+This is not useful for set operations. It facilitates encoding data that is not
+necessarily aligned to 8 bits. It was originally designed to cater to the
+packed encoding required for the ISO/IEC 20248 digital signature format.
## Usage
@@ -34,5 +38,11 @@ func main() {
var out uint
r.ReadBits(&out, 16)
fmt.Printf("%08b\n", out) // => 1011010000000101
+
+ ba.ShiftL(2)
+ fmt.Println(ba.String()) // => [11010000 000101--]
+
+ ba2, _ := ba.Slice(9, 6)
+ fmt.Println(ba2.String()) // => [000101--]
}
```