In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.