What are the operators built into the Go language
This article mainly explains "what are the built-in operators in the Go language". The explanation in the article is simple and clear and easy to learn and understand. please follow the editor's train of thought to study and learn "what are the operators built in the Go language"?
Catalogue
Overview
Go operator
Arithmetic operator
Relational operator
Logical operator
Assignment operator
Overview
Golang is a cross-platform new programming language. Today, Xiaobai will take you into the world of Golang hand in hand.
Go operator
Operators (operator) can help us to perform mathematical or logical operations in a program.
The operators built into the Go language are:
Arithmetic operator
Relational operator
Logical operator
Bit operator
Assignment operator
Arithmetic operator description + addition-subtraction * multiplication / division% remainder + + self-increment-self-subtraction
Example:
Package mainimport "fmt" func main () {/ / define variable var a = 10 var b = 2 / / debug output fmt.Println (a + b) / / add fmt.Println (a-b) / / subtract fmt.Println (a * b) / / multiply fmt.Println (a / b) / / divide Fmt.Println (a% b) / / take remainder / / self-add & self-subtract axiom + bMel-fmt.Println (a) / / self-add fmt.Println (b) / / self-subtract}
Output result:
twelve
eight
twenty
five
0
eleven
one
The relational operator description = = checks whether two values are equal. Returns True if equal, otherwise returns false = checks whether the two values are not equal, returns True if not, otherwise returns False > greater than = greater than or equal to b) fmt.Println (a)
< b) fmt.Println(a >= b) fmt.Println (a 1) / / 00011110: 30}
Output result:
twelve
sixty-one
forty-nine
one hundred and twenty
thirty
Assignment operator description = simple assignment + = add and then assign-= subtract and then assign / = divide and assign% = assign after remainder
Example:
Package mainimport "fmt" func main () {/ / define the variable var a = 10 var b = 2 var c int / / assignment operator c = a fmt.Println (c) b + = 2 fmt.Println (b) b-= 2 fmt.Println (b) a * = 2 fmt.Println (a ) a / = 2 fmt.Println (a) a% = 3 fmt.Println (a)}
Output result:
ten
four
two
twenty
ten
one
Thank you for your reading, the above is the content of "what are the operators built in the Go language". After the study of this article, I believe you have a deeper understanding of what the operators built in the Go language have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!