相关疑难解决方法(0)

C++标准规定了int的大小,long类型是什么?

我正在寻找有关基本C++类型大小的详细信息.我知道这取决于架构(16位,32位,64位)和编译器.

但是有没有C++的标准?

我在32位架构上使用Visual Studio 2008.这是我得到的:

char  : 1 byte
short : 2 bytes
int   : 4 bytes
long  : 4 bytes
float : 4 bytes
double: 8 bytes
Run Code Online (Sandbox Code Playgroud)

我试图找到,但没有成功,可靠的信息,表述的大小char,short,int,long,double,float(和其他类型的我没想到的),在不同的体系结构和编译器.

c++ c++-faq

679
推荐指数
15
解决办法
120万
查看次数

int的大小是否取决于编译器和/或处理器?

整数的大小是否取决于编译器,操作系统和处理器?

c c++ types

69
推荐指数
4
解决办法
4万
查看次数

在64位计算机上应该是sizeof(int)应该是什么?

可能重复:
int,long等
的大小int的大小是否取决于编译器和/或处理器?
什么决定整数的大小?

我正在使用一64-bit台机器.

$ uname -m
x86_64
$ file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped
$ 
Run Code Online (Sandbox Code Playgroud)

当我运行以下程序时,我得到了sizeof(int)as 4-bytes.

#include <stdio.h>

int main(void)
{
    printf("sizeof(int) = %d bytes\n", (int) sizeof(int));

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果我运行一个16-,32-64-位机,那么不就意味着一个大小integer16-,32-64-分别位?

在我的机器上,我找到了WORD_BITIS 32.它不应该6464-bit机器上吗?

$ getconf WORD_BIT
32 …
Run Code Online (Sandbox Code Playgroud)

c c++ sizeof

65
推荐指数
4
解决办法
15万
查看次数

Is there a currently used system with a C++ compiler where int is over 32 bits wide?

C++ standard says only that int has to be at least 16 bits wide. And at least according to cppreference, it's almost always either 16 or 32 bits wide:

data model       int width in bits
----------------------------------
C++ standard     at least 16
LP32             16
ILP32            32
LLP64            32
LP64             32
Run Code Online (Sandbox Code Playgroud)

...

Other models are very rare. For example, ILP64 (8/8/8: int, long, and pointer are 64-bit) only appeared in some early 64-bit Unix systems (e.g. Unicos on Cray).


Is …

c++ size int system bit

27
推荐指数
1
解决办法
928
查看次数

在新代码中,为什么要使用`int`而不是`int_fast16_t`或`int_fast32_t`作为计数变量?

如果您需要一个计数变量,肯定必须有一个整数必须支持的上限和下限.那么为什么不通过选择适当的(u)int_fastxx_t数据类型来指定这些限制呢?

c++ int c++11

9
推荐指数
2
解决办法
2277
查看次数

标签 统计

c++ ×5

c ×2

int ×2

bit ×1

c++-faq ×1

c++11 ×1

size ×1

sizeof ×1

system ×1

types ×1