当前位置:网站首页>[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-31 00:23:00 【HUAWEI CLOUD】
一、逻辑运算符
用于连接多个条件,一般来讲就是关系表达式,最终的结果也是一个 bool 值.
1.逻辑运算符的概念
| 运算符 | 说明 | 示例 |
|---|---|---|
| && | 逻辑 AND 运算符.如果两边的操作数都是 True,则条件 True,否则为 False | (A && B) 为 False |
| II | 逻辑 OR 运算符.如果两边的操作数有一个 True,则条件 True,否则为 False | (A II B) 为 True |
| ! | 逻辑 NOT 运算符.如果条件为 True,则逻辑 NOT 条件 False,否则为 True | !(A && B) 为 True |
相关案例:
package mainimport "fmt"func main() { var a bool = true var b bool = false if a && b { fmt.Printf("第一行 - 条件为 true \n") } if a || b { fmt.Printf("第二行 - 条件为 true \n") } // 修改 a 和 b 的值 a = false b = true if a && b { fmt.Printf("第三行 - 条件为 true \n") } else { fmt.Printf("第三行 - 条件为 false \n") } if !(a && b) { fmt.Printf("第四行 - 条件为 true \n") }}
二、其他运算符
1.位运算符的概念
| 运算符 | 说明 | 示例 |
|---|---|---|
| & | 如果两个操作数中都存在二进制AND运算符,则将其复制到结果. | (A&B)结果为12,也就是0000 1100 |
| I | 二进制OR运算符复制一个位,如果它存在于任一操作数. | (AIB)结果为61,也就是0011 1101 ^ 二进制XOR运算符复制位,如果它在一个操作数中设置,但不是在两个操作数中设置. (A^B)结果为49,也就是0011 0001 |
| << | 二进制左移位运算符.左操作数值向左移动由右操作数指定的位数. | A<<2结果为240,也就是1111 0000 |
| >> | 二进制右移运算符.左操作数值向右移动由右操作数指定位数. | A>>2结果为15,也就是0000 1111 |
2.地址相关运算符的概念
| 运算符 | 说明 | 示例 |
|---|---|---|
| & | 返回变量的地址 | &a将给出变量a的实际地址. |
* | 指向变量的指针 | *a是指向变量a的指针. |
边栏推荐
- Neural Network (ANN)
- ES6中 async 函数、await表达式 的基本用法
- firewalld
- MySQL系列一:账号管理与引擎
- [In-depth and easy-to-follow FPGA learning 15---------- Timing analysis basics]
- WMware Tools安装失败segmentation fault解决方法
- Jmeter parameter transfer method (token transfer, interface association, etc.)
- 【唐宇迪 深度学习-3D点云实战系列】学习笔记
- MySQL中substring与substr区别
- Steven Giesel 最近发布了一个由5部分内容组成的系列,记录了他首次使用 Uno Platform 构建应用程序的经验。
猜你喜欢

asser利用蚁剑登录

pytorch bilinear interpolation

Homework: iptables prevent nmap scan and binlog

software development design process

C language force buckles the rotating image of the 48th question.auxiliary array

DNS解析过程【访问网站】

Shell script if statement

Optimization of aggregate mentioned at DATA AI Summit 2022

Restricted character bypass

How to solve types joiplay simulator does not support this game
随机推荐
Basic usage of async functions and await expressions in ES6
h264和h265解码上的区别
Bypass of xss
IOT cross-platform component design scheme
Error ER_NOT_SUPPORTED_AUTH_MODE Client does not support authentication protocol requested by serv
MySQL Series 1: Account Management and Engine
Restricted character bypass
firewalld
MySQL数据库进阶篇
How to solve types joiplay simulator does not support this game
binglog日志追踪:数据备份并备份追踪
Point Cloud Scene Reconstruction with Depth Estimation
WEB Security Basics - - - Vulnerability Scanner
How to solve the error of joiplay simulator
SWM32系列教程6-Systick和PWM
MySQL table design for message queue to store message data
joiplay模拟器报错如何解决
MySql数据恢复方法个人总结
xss的绕过
论文理解:“Designing and training of a dual CNN for image denoising“