问题描述
我有几个问题:
是否需要 64 位处理器才能使用 64 位数据类型(__int64 或 int64_t)?
Do I need to have 64 bit Processor to use 64 bit data type(__int64 or int64_t) ?
int64_t 的t"是什么意思?
What means by, the "t" of int64_t?
从哪个版本的 GCC 和 VCC 开始支持数据类型?
Starting from what version of GCC and VCC are supporting data type?
是 64 位数据类型只是将数据长度增加了一倍,还是还有其他一些事情在幕后?
Is the 64 bit data type are just doubling the data length or there are some other things going under the hood too?
推荐答案
使用 64 位数据类型不需要 64 位处理器.这一切都取决于编译器,而且只取决于编译器.如果需要,编译器可以为您提供 128 位、237 位或 803 位数据类型.
You don't need 64 bit processor to use 64 bit data type. It all depends on the compiler and only on the compiler. The compiler can provide you with 128-bit, 237-bit or 803-bit data types, if it so desires.
但是,请记住,通常 32 位 CPU 不能直接处理 64 位值,这意味着支持 64 位类型的所有必要语言操作的负担在于编译器和库.编译器必须生成或多或少复杂的 32 位 CPU 指令序列,以便对 64 位值执行加法、移位、乘法等.这意味着在为 32 位 CPU 生成的代码中,对 64 位数据类型的基本语言操作不会像在为 64 位 CPU 生成的代码中那样有效(因为在后者中,大多数语言操作将由单个 CPU 指令).
However, keep in mind that normally 32-bit CPUs cannot handle 64-bit values directly, which means that the burden of supporting all necessary language operations for 64-bit type lies on the compiler and the library. The compiler will have to generate a more-or-less complex sequence of 32-bit CPU instructions in order to perform additions, shifts, multiplications etc. on 64-bit values. This means that in code generated for 32-bit CPUs basic language operations on 64-bit data types will not be as efficient as they would be in code generated for 64-bit CPUs (since in the latter most language operations would be carried out by a single CPU instruction).
int64_t
中的t"代表type"或typedef name".这是标准库 typedef 的旧命名约定.
The "t" in int64_t
stands for either "type" or "typedef name". That's an old accepted naming convention for standard library typedefs.
至于编译器版本,其实是一个模棱两可的问题.typedef 名称 int64_t
是 C 语言(但不是 C++ 语言)标准库的一部分,而对 64 位整数类型(任何名称)的支持是编译器的一部分.所以你问的是哪一个?例如,MSVC 编译器长期以来一直支持 64 位数据类型,但是这些类型的名称一直不同.64 位有符号整数在 MSVC 中被称为 __int64
.至于 int64_t
typedef,AFAIK,即使在今天,它也不是 MSVC 标准库的一部分.事实上,int64_t
从其规范的 C99 版本开始成为 C 语言的一部分.同时它不是C++语言的一部分.因此,一般而言,无论编译器版本如何,您都不应该期望在 C++ 代码中使用 int64_t
.
As for compiler versions, it is an ambiguous question actually. The typedef name int64_t
is a part of the standard library of C language (but not of C++ language), while the support for 64-bit integer types (under any name) is a part of the compiler. So which one are you asking about? For example, MSVC compiler has been supporting 64-bit data types for a long time, but the names for these types have been different. 64-bit signed integer is called __int64
of something like that in MSVC. As for the int64_t
typedef, AFAIK, it is not a part of MSVC's standard library even today. In fact, int64_t
became a part of C language from the C99 version of its specification. At the same time it is not a part of C++ language. So, generally, you are not supposed to expect to have int64_t
in C++ code regardless of the version of the compiler.
至于数据长度......嗯,是的,它只是将位数增加了一倍.其余的如下.
As for data length... Well, yeah, it is just doubling the number of bits. The rest follows.
这篇关于我是否需要有 64 位处理器才能使用 64 位数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!