Complete Embedded Artificial Intelligence study notes ---- "Embedded Basics 1.3_C language ___ operators and expressions"

<Operators and expressions>
-> expression and arithmetic operators

Operators description Synthesis
+ Monocular positive From right to left
- Monocular negative From right to left
* Multiply from left to right
/ In addition to and divisible from left to right
% Remainder from left to right

-> assignment operator and expressions
1. simple assignment operator: '='
2. meet assignment operator: '= +', '- =', '* =' '/ =', '% ='
3 particular assignment operator: '+', '-'
-> comma operator and expressions
in the C language comma operator is also a, its function is to connect together two expressions
, for example: a = (x = a + b), (b + c)

-> bitwise and expressions
1 and operator (&)

Left computation Right computation & Operation result
0 0 0
0 1 0
1 0 0
1 1 1

2. OR operator (|)

Left computation Right computation Shu result of the operation
0 0 0
0 1 1
1 0 1
1 1 1

3. The exclusive-OR operator (^)

Left computation Right computation ^ Operation result
0 0 0
0 1 1
1 0 1
1 1 0

4. bitwise operator ( "<<" or ">>")
is generally in the form of shift operation: <computation> <Operator> <Expression>

-> relational operators and expressions

Operators Function Description
> more than the
>= greater or equal to
< Less than
<= Less than or equal
== equal
!= Unequal

-> Logical operators and expressions
1. The logical operators (&&)
binary operator, only two calculation amounts are 1, the result was 1.

Left computation Right computation && operation result
0 0 0
0 1 0
1 0 0
1 1 1

2. Logical Operators (Shushu)
When two operation amount calculation, as long as there is a 1, the result is 1.

Left computation Right computation Shu Shu result of the operation
0 0 0
0 1 1
1 0 1
1 1 1

3. Non-operator (!)
Unary operators, when calculating the amount of non-operation, the result negated.

运算量 !运算结果
0 1
1 0

->sizeof操作符
sizeof是一个单目运算符,它的运算对象是变量或数据类型,运算结果为一个整数。运算的一般形式siziof(<类型或变量名>)
->条件运算符
条件运算符(? :)是C语言中的唯一一个三目运算符他可以提供if--then--else语句的简易操作
<表达式1>?<表达式2>:<表达式3>
例如:(a = 5;b = 1)a>b? yes:no ---> 结果返回yes
->运算符优先级
内容较多,不再详细说明
运算符的优先级口诀

--------口诀--------
括号成员第一
全体单目第二
乘除余三,加减四
移位五,关系六
等于与不等排第七

Guess you like

Origin blog.51cto.com/11444021/2418741