How to use the bit operator in Go language
This article mainly explains "how to use the bit operator in Go language". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the bit operator in Go language.
Example
Package main
Import "fmt"
Func main () {
Var a uint = 60 / * 60 = 0011 1100 * /
Var b uint = 13 / * 13 = 0000 1101 * /
Var c uint = 0
C = a & b / * 12 = 0000 1100 * /
Fmt.Printf ("the value of the first line-c is% d\ n", c)
C = a | b / * 61 = 0011 1101 * /
Fmt.Printf ("the value of the second line-c is% d\ n", c)
C = a ^ b / * 49 = 0011 0001 * /
Fmt.Printf ("the value of the third line-c is% d\ n", c)
C = a > 2 / * 15 = 0000 1111 * /
Fmt.Printf ("the value of line 5-c is% d\ n", c)
}
The running result of the above instance:
The value of the first row-c is 12. The second line-c is 61. The third line-c is 49. The fourth line-c is 240. the fifth line-c is 15. Thank you for reading. The above is the content of "how to use the bit operator in Go language". After the study of this article, I believe you have a deeper understanding of how to use the bit operator in Go language. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!