int和long有什么不同?

如题所述

不一样。

在一般的电脑中,int数据范围为-2147483648~2147483647[-2^31~2^31-1];

long取值范围:-2147483647 到 2147483647 ,即为 -(2^31 - 1) 到 (2^31 - 1)。

int 是 C 语言的基本整数类型,可以满足处理一般数据的需求。C 语言还提供了四个可以修饰 int 的关键字:short、long、signed,以及 unsigned。

扩展资料:

利用这四个关键字:short、long、signed,以及 unsigned,C 语言标准定义了以下整数类型: 

1) short int(可简写为 short),和 int 一样,也是有符号整数

2) long int(简写:long),有符号整数

3) long long int(简写:long long),C99 标准添加的类型,有符号整数

4) unsigned int(简写:unsigned),无符号整数,不能表示负数

5) unsigned long int(简写:unsigned long),无符号整数,不能表示负数

6) unsigned short int(简写:unsigned short),无符号整数,不能表示负数

7) unsigned long long int(简写:unsigned long long),C99 添加的类型,无符号整数

8) 所有没有标明 unsigned 的整数类型默认都是有符号整数。

参考资料:百度百科-长整型

温馨提示:答案为网友推荐,仅供参考