Skip to content

Commit

Permalink
add LenBytes function
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalick committed Oct 16, 2021
1 parent bb02d5b commit 7f77dad
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bitslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ func (s BitSlice) Len() int {
return len(s.Slice)
}

//LenBytes return length of slice
func (s BitSlice) LenBytes() int {
lenBits := s.Len()
lenBytes := lenBits / 8
if lenBits%8 > 0 {
lenBytes += 1
}
return lenBytes
}

//ShiftLeft returns shifted BitSlice, like << operation
func (s BitSlice) ShiftLeft(val int) BitSlice {
if val < 0 {
Expand Down

0 comments on commit 7f77dad

Please sign in to comment.