I have a few questions:
我有几个问题:
-
Do I need to have 64 bit Processor to use 64 bit data type(__int64 or int64_t) ?
我需要64位处理器来使用64位数据类型(__int64或int64_t)吗?
-
What means by, the "t" of int64_t?
int64_t的“t”是什么意思?
-
Starting from what version of GCC and VCC are supporting data type?
从哪个版本的GCC和VCC开始支持数据类型?
-
Is the 64 bit data type are just doubling the data length or there are some other things going under the hood too?
64位数据类型是将数据长度翻倍还是有其他的东西在背后?
4 个解决方案
#1
17
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.
您不需要64位处理器来使用64位数据类型。这一切都取决于编译器,而且只取决于编译器。如果需要,编译器可以为您提供128位、237位或803位的数据类型。
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).
但是,请记住,通常32位的cpu不能直接处理64位值,这意味着支持64位类型的所有必要语言操作的重担在于编译器和库。编译器必须生成一个或多或少复杂的32位CPU指令序列,以便对64位值执行添加、移位、乘法等操作。这意味着在为32位的CPU生成的代码中,对于64位数据类型的基本语言操作将不会像在64位CPU中生成的代码那样高效(因为在后者中,大多数语言操作都是由一个CPU指令执行的)。
The "t" in int64_t
stands for either "type" or "typedef name". That's an old accepted naming convention for standard library typedefs.
int64_t中的“t”代表“type”或“typedef name”。这是标准库typedef的旧命名约定。
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.
对于编译器版本,实际上是一个模糊的问题。typedef name int64_t是C语言标准库(但不是c++语言)的一部分,而对64位整数类型(任何名称下)的支持是编译器的一部分。你问的是哪一个?例如,MSVC编译器长期以来一直支持64位数据类型,但是这些类型的名称不同。在MSVC中,64位有符号整数被称为__int64。至于int64_t类型定义AFAIK,它甚至不是MSVC标准库的一部分。事实上,int64_t从C99版本的规范变成了C语言的一部分。同时它也不是c++语言的一部分。因此,一般来说,无论编译器的版本是什么,都不应该期望在c++代码中有int64_t。
As for data length... Well, yeah, it is just doubling the number of bits. The rest follows.
至于数据长度……是的,它是比特数的两倍。其余的遵循。
#2
8
- No, you can process such data on a 32 bit machine. So long as your compiler supports those data types you are fine.
- 不,您可以在32位机器上处理这些数据。只要编译器支持这些数据类型,就可以了。
- int64_t is just its name, as defined in the standard.
- int64_t只是它的名称,在标准中定义。
- I think all versions of GCC and MSVC this century support 64 bit integers on 32 bit architecture.
- 我认为本世纪所有版本的GCC和MSVC都支持32位架构上的64位整数。
- A 64 bit integer is just twice the size of a 32 bit integer.
- 64位整数的大小是32位整数的两倍。
#3
3
If you look at /usr/include/stdint.h
, you'll find that int64_t
is defined as
如果你看/usr/include/ stdintin。h,你会发现int64_t被定义为
typedef long long int int64_t;
So, as David said, it's compiler and not architecture dependent.
正如David所说,它是编译器而不是依赖于体系结构。
#4
0
No, compilers on 32bit architectures emulate 64bit arithmetic. It's not terribly fast, but it's not that bad.
不,32位架构上的编译器模拟64位算法。它不是很快,但也没那么糟糕。
The t
refers to type
. This is legacy from C where structs would have to be referred to differently.
t表示类型。这是来自C的遗留问题,在C中结构体必须被不同地引用。
64bit integral types may have increased alignment, but that's about it.
64位积分类型可能增加了对齐,但仅此而已。
I've no idea for point 3.
我不知道点3。
#1
17
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.
您不需要64位处理器来使用64位数据类型。这一切都取决于编译器,而且只取决于编译器。如果需要,编译器可以为您提供128位、237位或803位的数据类型。
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).
但是,请记住,通常32位的cpu不能直接处理64位值,这意味着支持64位类型的所有必要语言操作的重担在于编译器和库。编译器必须生成一个或多或少复杂的32位CPU指令序列,以便对64位值执行添加、移位、乘法等操作。这意味着在为32位的CPU生成的代码中,对于64位数据类型的基本语言操作将不会像在64位CPU中生成的代码那样高效(因为在后者中,大多数语言操作都是由一个CPU指令执行的)。
The "t" in int64_t
stands for either "type" or "typedef name". That's an old accepted naming convention for standard library typedefs.
int64_t中的“t”代表“type”或“typedef name”。这是标准库typedef的旧命名约定。
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.
对于编译器版本,实际上是一个模糊的问题。typedef name int64_t是C语言标准库(但不是c++语言)的一部分,而对64位整数类型(任何名称下)的支持是编译器的一部分。你问的是哪一个?例如,MSVC编译器长期以来一直支持64位数据类型,但是这些类型的名称不同。在MSVC中,64位有符号整数被称为__int64。至于int64_t类型定义AFAIK,它甚至不是MSVC标准库的一部分。事实上,int64_t从C99版本的规范变成了C语言的一部分。同时它也不是c++语言的一部分。因此,一般来说,无论编译器的版本是什么,都不应该期望在c++代码中有int64_t。
As for data length... Well, yeah, it is just doubling the number of bits. The rest follows.
至于数据长度……是的,它是比特数的两倍。其余的遵循。
#2
8
- No, you can process such data on a 32 bit machine. So long as your compiler supports those data types you are fine.
- 不,您可以在32位机器上处理这些数据。只要编译器支持这些数据类型,就可以了。
- int64_t is just its name, as defined in the standard.
- int64_t只是它的名称,在标准中定义。
- I think all versions of GCC and MSVC this century support 64 bit integers on 32 bit architecture.
- 我认为本世纪所有版本的GCC和MSVC都支持32位架构上的64位整数。
- A 64 bit integer is just twice the size of a 32 bit integer.
- 64位整数的大小是32位整数的两倍。
#3
3
If you look at /usr/include/stdint.h
, you'll find that int64_t
is defined as
如果你看/usr/include/ stdintin。h,你会发现int64_t被定义为
typedef long long int int64_t;
So, as David said, it's compiler and not architecture dependent.
正如David所说,它是编译器而不是依赖于体系结构。
#4
0
No, compilers on 32bit architectures emulate 64bit arithmetic. It's not terribly fast, but it's not that bad.
不,32位架构上的编译器模拟64位算法。它不是很快,但也没那么糟糕。
The t
refers to type
. This is legacy from C where structs would have to be referred to differently.
t表示类型。这是来自C的遗留问题,在C中结构体必须被不同地引用。
64bit integral types may have increased alignment, but that's about it.
64位积分类型可能增加了对齐,但仅此而已。
I've no idea for point 3.
我不知道点3。