20 lines
1.2 KiB
Go
20 lines
1.2 KiB
Go
/*
|
|
Package bit aims to provide feature parity with stdlib's [encoding/hex].
|
|
|
|
It's a ludicrous tragedy that hex/base16, base32, base64 all have libraries for converting
|
|
to/from string representations... but there's nothing for binary ('01010001' etc.) whatsoever.
|
|
|
|
This package also provides some extra convenience functions and types in an attempt to provide
|
|
an abstracted bit-level fidelity in Go. A [Bit] is a bool type, in which that underlying bool
|
|
being false represents a 0 and that underlying bool being true represents a 1.
|
|
|
|
Note that a [Bit] or arbitrary-length or non-octal-aligned [][Bit] may take up more bytes in memory
|
|
than expected; a [Bit] will actually always occupy a single byte -- thus representing
|
|
`00000000 00000000` as a [][Bit] or [16][Bit] will actually occupy *sixteen bytes* in memory,
|
|
NOT 2 bytes (nor, obviously, [2][Byte])!
|
|
It is recommended instead to use a [Bits] instead of a [Bit] slice or array, as it will try to properly align to the
|
|
smallest memory allocation possible (at the cost of a few extra CPU cycles on adding/removing one or more [Bit]).
|
|
It will properly retain any appended, prepended, leading, or trailing bits that do not currently align to a byte.
|
|
*/
|
|
package bit
|