# 有关C语言中有符号/无符号数混合运算的小问题

1。操作数全为有符号数

int a = -1;
int b = 2;
a + b;

2。操作数全为无符号数

unsigned int a = (unsigned int)-1;
unsigned int b = 2;
a + b;

3。操作数混合了有符号数，无符号数

int a = -1;
unsigned int b = 2;
a / b;

int main()
{

signed int n1 = 1;
signed int n2 = 2;
unsigned int u1 = 1;
unsigned int u2 = 2;

signed int a = n1 + n2;
unsigned int ua = u1 + u2;

signed int s = n1 - n2;
unsigned int us = u1 - u2;

signed int m = n1 * n2;
unsigned int um = u1 * u2;

signed int d = n1 / n2;
unsigned int d = u1 / u2;

signed int m = n1 % n2;
unsigned int um = u1 % u2;

return 0;
}

(unsigned int)a / (signed int)b

(unsigned int)a / (unsigned int)b

#### c语言之无符号/有符号数加减法运算

2015-08-28 17:09:17

#### C语言 有符号数和无符号数的移位运算

2015-02-23 18:35:22

#### C语言系列（二）有符号数和无符号数详解

2016-08-07 15:39:36

#### c语言中无符号和有符号之间的运算

2015-04-03 23:22:45

#### C++中含有无符号类型的表达式——有符号数与无符号数相加

2017-08-02 09:26:12

#### 有符号整数除以无符号整数会发生什么？？！！！

2017-04-21 22:07:42

#### C语言中有符号数与无符号数相加

2017-05-06 22:53:57

#### 有符号数与无符号数之间的运算

2017-08-17 21:16:58

#### C语言中无符号数和有符号数之间的运算

2017-09-12 11:34:02

#### 汇编语言中使用有符号数还是无符号数问题

2015-06-29 20:52:34