You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
268 B
Go

package bit
type Bit byte
func (b *Bit) Flip() {
(*b) ^= 0x01
}
type Bits []Bit
func (bits *Bits) Bytes() []byte {
var l = len(*bits)
var o = make([]byte, (l+7)/8)
for i, b := range *bits {
if b == 0x01 {
o[i/8] |= (1 << byte(7-(i%8)))
}
}
return o
}