字节取位小技巧
b := make([]byte, 1) b[0] = 255 fmt.Printf("%b\n", b[0]) //11111111 fmt.Printf("%b\n", b[0]>>7)//1
fmt.Printf("%b\n", (b[0]>>6) & 1)// = 11 & 01 = 1
posted on 2018-09-13 14:06 darkness_1 阅读(194) 评论(0) 编辑 收藏 举报
b := make([]byte, 1) b[0] = 255 fmt.Printf("%b\n", b[0]) //11111111 fmt.Printf("%b\n", b[0]>>7)//1
fmt.Printf("%b\n", (b[0]>>6) & 1)// = 11 & 01 = 1
posted on 2018-09-13 14:06 darkness_1 阅读(194) 评论(0) 编辑 收藏 举报