Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample to check if the `n` bit of a `a` byte is true or false
package main
import (
"fmt"
)
func main() {
var a byte
a = 0x02
fmt.Printf("%08b\n", a)
n := 1
_bit := uint32(n % 8)
b := ((a & (1 << _bit)) != 0)
fmt.Println("!", b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.