int_least64_t VS int_fast64_t VS的int64_t [英] int_least64_t vs int_fast64_t vs int64_t

查看:1122
本文介绍了int_least64_t VS int_fast64_t VS的int64_t的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的口code到64位。

I'm trying to port my code to 64bit.

我发现,C ++提供了64位整型,但我仍然感到困惑了。

I found that C++ provides 64bit integer types, but I'm still confused about it.

首先,我发现了四个不同的64位 INT S:

First, I found four different 64bit ints:

int_least64_t
int_fast64_t
int64_t
intmax_t

和其对应的无符号。我测试了他们使用的sizeof(),他们是8个字节,使他们64位。

and their unsigned counterparts. I tested them using sizeof() and they are 8 byte so they are 64bit.

什么是它们之间的不同呢?什么是的至少快捷类型的含义?那么还会将intmax_t

What's the different between them? What is the meaning of the least and fast types? What about intmax_t?

推荐答案

在你的平台上,他们为相同的基础数据类型的所有名称。在其他平台上,他们不是。

On your platform, they're all names for the same underlying data type. On other platforms, they aren't.

的int64_t 要求是完全64位。与(例如)一个9位字节体系结构中,将不提供在所有的

int64_t is required to be EXACTLY 64 bits. On architectures with (for example) a 9-bit byte, it won't be available at all.

int_least64_t 是至少64位的最小数据类型。如果的int64_t 可用,将使用它。但(例如)与9位字节机,这可能是72比特。

int_least64_t is the smallest data type with at least 64 bits. If int64_t is available, it will be used. But (for example) with a 9-bit byte machine, this could be 72 bits.

int_fast64_t 是至少有64位,最好的运算性能的数据类型。它的存在主要是为了与 int_fast8_t 一致性和 int_fast16_t ,它在多台机器将是32位,而不是8或16。再过几年,也可能是一个体系结构,其中128位数学比64位的快,但我不认为今天存在的话。

int_fast64_t is the data type with at least 64 bits and the best arithmetic performance. It's there mainly for consistency with int_fast8_t and int_fast16_t, which on many machines will be 32 bits, not 8 or 16. In a few more years, there might be an architecture where 128-bit math is faster than 64-bit, but I don't think any exists today.

如果您正在移植的算法,你可能想使用 int_fast32_t ,因为它持有的任何值旧的32位code就可以搞定,但将是64位的,如果这是速度更快。如果你将指向整数(为什么?),然后使用使用intptr_t

If you're porting an algorithm, you probably want to be using int_fast32_t, since it will hold any value your old 32-bit code can handle, but will be 64-bit if that's faster. If you're converting pointers to integers (why?) then use intptr_t.

这篇关于int_least64_t VS int_fast64_t VS的int64_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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