Browse Source

Fixed utils

main
Unbewohnte 3 years ago
parent
commit
9d94b9a857
  1. 4
      util/bits.go

4
util/bits.go

@ -3,7 +3,7 @@ package util
// Tells if bit is set in given byte,
// if bitN <= 0 - always returns false
func GetBit(b byte, bitN int) bool {
if bitN == 0 {
if bitN <= 0 {
return false
}
return b&byte(1<<bitN-1) != 0
@ -12,7 +12,7 @@ func GetBit(b byte, bitN int) bool {
// Sets bit to 1 in provided byte, if bitN <= 0
// returns original b without modifications
func SetBit(b byte, bitN int) byte {
if bitN == 0 {
if bitN <= 0 {
return b
}
return b | byte(1<<byte(bitN)-1)

Loading…
Cancel
Save