当前位置:网站首页>[Yugong series] July 2022 go teaching course 016 logical operators and other operators of operators
[Yugong series] July 2022 go teaching course 016 logical operators and other operators of operators
2022-07-25 06:43:00 【Yugong move code】
List of articles
One 、 Logical operators
Used to connect multiple conditions , In general, it's a relational expression , The end result is also a bool value .
1. The concept of logical operators
| Operator | explain | Example |
|---|---|---|
| && | Logic AND Operator . If the operands on both sides are True, Then the condition is True, Otherwise False | (A && B) by False |
| II | Logic OR Operator . If the operands on both sides have one True, Then the condition is True, Otherwise False | (A II B) by True |
| ! | Logic NOT Operator . If the condition is True, Then logic NOT Conditions False, Otherwise True | !(A && B) by True |
Related cases :
package main
import "fmt"
func main() {
var a bool = true
var b bool = false
if a && b {
fmt.Printf(" first line - Condition is true \n")
}
if a || b {
fmt.Printf(" The second line - Condition is true \n")
}
// modify a and b Value
a = false
b = true
if a && b {
fmt.Printf(" The third line - Condition is true \n")
} else {
fmt.Printf(" The third line - Condition is false \n")
}
if !(a && b) {
fmt.Printf(" In the fourth row - Condition is true \n")
}
}

Two 、 Other operators
1. The concept of bitwise operators
| Operator | explain | Example |
|---|---|---|
| & | If binary exists in both operands AND Operator , Then copy it to the result . | (A&B) The result is 12, That is to say 0000 1100 |
| I | Binary system OR Operator copies a bit , If it exists in any of the operands . | (AIB) The result is 61, That is to say 0011 1101 ^ Binary system XOR Operator copy bit , If it is set in an operand , But not in two operands . (A^B) The result is 49, That is to say 0011 0001 |
| << | Binary left shift operator . The left operand moves left by the number of bits specified by the right operand . | A<<2 The result is 240, That is to say 1111 0000 |
| >> | Binary right shift operator . The left operand moves to the right, and the number of digits specified by the right operand . | A>>2 The result is 15, That is to say 0000 1111 |
2. Concept of address dependent operators
| Operator | explain | Example |
|---|---|---|
| & | Return the address of the variable | &a The variable will be given a The actual address of . |
* | Pointer to variable | *a Is pointing to variables a The pointer to . |
边栏推荐
- 都说ScreenToGif是GIF录制神器,却不知其强大之处远不在此
- JZ7 rebuild binary tree
- Simple factory factory method Abstract Factory
- In container multicast
- The code spell checker plug-in avoids some specific vocabulary errors "XXX": unknown word.cspell
- 长安链双花交易防范策略
- Keil uvisin5 code auto completion or code Association
- 【datawhale202207】强化学习:策略梯度和近端策略优化
- Thread 类的基本用法
- 机器人工程-教学品质-如何判定
猜你喜欢

【C】程序环境和预处理

Koa2 learning

【datawhale202207】强化学习:策略梯度和近端策略优化

100 GIS practical application cases (seventeen) - making 3D map based on DEM

Health clock in daily reminder tired? Then let automation help you -- hiflow, application connection automation assistant

百度希壤首场元宇宙拍卖落槌,陈丹青六幅版画作品全部成交!

Do you know the same period last year in powerbi

Observer mode

MySQL remote login

Labelme labels different objects, displays different colors and batch conversion
随机推荐
Koa2 learning
When the graduation season comes, are you ready? What are we going to do
It is said that screentogif is a GIF recording artifact, but I don't know that its strength is far from here
Over adapter mode
Simple factory factory method Abstract Factory
Seekbar attribute reference
A scene application of 2D animation
Health clock in daily reminder tired? Then let automation help you -- hiflow, application connection automation assistant
[C language] in depth understanding of pointers and arrays (phase I)
C#--MetroFramework框架调用metroModernUI库,并在工具栏使用
Mysql database
Classic cases of static keywords and block blocks
【愚公系列】2022年7月 Go教学课程 015-运算符之赋值运算符和关系运算符
“font/woff“ and “font/woff2“ in file “mime.types“
VSCode 如何开启多个终端?如何横向显示?
The code spell checker plug-in avoids some specific vocabulary errors "XXX": unknown word.cspell
【剑指Offer】模拟实现atoi
Software engineering in Code: regular expression ten step clearance
Application of first-order complementary filtering to STM32 ADC acquisition
How to troubleshoot the problem of too many inodes