Difference between long and int data types(long 和 int 数据类型之间的区别)
问题描述
考虑到以下语句返回4
,C++中的int
和long
类型有什么区别?
Considering that the following statements return 4
, what is the difference between the int
and long
types in C++?
sizeof(int)
sizeof(long)
推荐答案
来自 this 参考:
一个 int 原本打算是的自然"字长处理器.许多现代处理器可以以相等的方式处理不同的字长轻松.
An int was originally intended to be the "natural" word size of the processor. Many modern processors can handle different word sizes with equal ease.
还有,这一点:
在许多(但不是全部)C 和 C++ 上实现,长大于一个整数.当今最流行的桌面平台,如 Windows 和 Linux,主要运行在 32 位处理器和这些平台的大多数编译器使用具有相同大小的 32 位 int并以长表示.
On many (but not all) C and C++ implementations, a long is larger than an int. Today's most popular desktop platforms, such as Windows and Linux, run primarily on 32 bit processors and most compilers for these platforms use a 32 bit int which has the same size and representation as a long.
这篇关于long 和 int 数据类型之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:long 和 int 数据类型之间的区别


基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07