我需要有64位处理器使用64位数据类型 [英] Do I need to have 64 bit Processor to use 64 bit data type

查看:132
本文介绍了我需要有64位处理器使用64位数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个问题:

  1. 我是否需要有64位处理器使用64位数据类型(__的Int64或的int64_t)?

  2. 什么是指,T型的的int64_t?

  3. 从GCC和VCC是什么版本开始都支持的数据类型?

  4. 是64位的数据类型,只是增加一倍,数据长度还是有一些其他的东西引擎盖下会吗?

解决方案

您并不需要64位处理器使用64位数据类型。这一切都取决于编译器,只有编译器。编译器可以为您提供128位,237位或803位的数据类型,如果是这样的欲望。

但是,请记住,通常32位CPU不能直接处理64位值,这意味着支持所有必要的语言操作的64位类型的责任在于编译器。编译器将不得不产生更多或更少的复杂的32位CPU指令序列,以执行加法,移位,乘法等上的64位值。这意味着,在code产生的64位数据类型32位CPU的基本语言操作将不被视为有效,因为他们将是code的64位CPU产生的(因为后者最语言操作将被执行由单个CPU指令)。

T型的的int64_t 表示无论是型或typedef名称。这对标准库的typedef一个老公认的命名约定。

至于编译器版本,它实际上是一个模糊的问题。 typedef名的int64_t 是C语言的标准库的一部分(但的C不++语言),而对于64位整数类型的支持(在任何名称)是编译器的一部分。那么,哪一个你要问什么?例如,MSVC编译器已经支持64位数据类型很长一段时间,但对于这些类型的名称有所不同。 64位有符号整数叫做 __的Int64 的类似的东西在MSVC。而对于的int64_t 的typedef,AFAIK,它不是MSVC的即使在今天,标准库的一部分。事实上,的int64_t 成为C语言的C99版本的规范的一部分。同时这不是C ++语言的一部分。所以,一般情况下,你不应该期望有的int64_t 在C ++中code不管编译器的版本。

对于数据长度......嗯,是的,它只是增加了一倍位数。其余如下。

I have a few questions:

  1. Do I need to have 64 bit Processor to use 64 bit data type(__int64 or int64_t) ?

  2. What means by, the "t" of int64_t?

  3. Starting from what version of GCC and VCC are supporting data type?

  4. Is the 64 bit data type are just doubling the data length or there are some other things going under the hood too?

解决方案

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.

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. 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).

The "t" in int64_t stands for either "type" or "typedef name". That's an old accepted naming convention for standard library typedefs.

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位数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆