是什么intXX_t和int_fastXX_t之间的区别? [英] What is the difference between intXX_t and int_fastXX_t?

查看:165
本文介绍了是什么intXX_t和int_fastXX_t之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现的存在标准的最快的类型,主要是<一个href=\"http://www.linuxbase.org/navigator/browse/type_single.php?cmd=display&Tid=16619\">int_fast32_t和<一个href=\"http://www.linuxbase.org/navigator/browse/type_single.php?cmd=display&Tid=16620\">int_fast64_t.

I have recently discovered existence of standard fastest type, mainly int_fast32_t and int_fast64_t.

我总是告诉,对于主流的建筑正常使用,应该更好地利用经典的 INT 的&安培;的的应该始终适合处理器默认的阅读能力,从而避免无用的数字转换。

I was always told that, for normal use on mainstream architecture, one should better use classical int & long which should always fit to the processor default reading capacity and so avoid useless numeric conversions.

在C99标准,它说在§7.18.1.3p2:

In the C99 Standard, it says in §7.18.1.3p2 :

typedef名int_fastN_t与至少N. typedef名uint_fastN_t表示与至少N的宽度最快无符号整型的宽度表示最快符号整数型。

"The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at least N."

和也有报价关于它的§7.18.1.3p1:

And there is also a quote about it in §7.18.1.3p1 :

指定的类型不保证是最快的为所有目的;如果实现了超过另一个选择一个类型没有明显的理由,这将只挑选满足符号性和宽度要求一些整型

"The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear grounds for choosing one type over another, it will simply pick some integer type satisfying the signedness and width requirements."

这我不清楚是什么最快的真正含义。我不明白的时候,我应该使用这种类型的,当我不应该。

It's unclear to me what fastest really means. I do not understand when I should use this type and when I should not.

我GOOGLE了一个小本上,发现了一些打开 已经改变了他们的一些功能,它/ 85610 />项目,但不是所有的人。他们并没有真正解释为什么他们已经改变了一部分,而的一部分,他们的code到它的。

I have googled a little on this and found that some open source projects have changed some of their functions to it, but not all of them. They didn't really explain why they have changed a part, and only a part, of their code to it.

你知道有什么特殊情况/用途时int_fastXX_t是的真正的比经典得更快?

Do you know what are the specific cases/usages when int_fastXX_t are really faster than the classical ones ?

推荐答案

在C99标准,7.18.1.3最快最小宽度整数类型。

In the C99 Standard, 7.18.1.3 Fastest minimum-width integer types.

(7.18.1.3p1)每个下列类型的指定的整数类型,通常是fastest225)与具有至少指定宽度所有整数类型之间进行操作。

(7.18.1.3p1) "Each of the following types designates an integer type that is usually fastest225) to operate with among all integer types that have at least the specified width."

225)指定的类型不保证是最快的用于所有目的;如果实现具有用于来选择其它类型没有明确的理由,它将简单地挑选满足带符号和宽度要求一些整数类型。

225) "The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear grounds for choosing one type over another, it will simply pick some integer type satisfying the signedness and width requirements."

(7.18.1.3p2)typedef名int_fastN_t指定最快的有符号整数类型至少有N的宽度typedef名uint_fastN_t指定最快的无符号整数
  与至少N的宽度输入

(7.18.1.3p2) "The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at least N."

类型 int_fastN_t uint_fastN_t 是同行确切的宽度整数类型 intN_t uintN_t 。实施保证,他们至少需要 N 位,但执行可以采取更多的位,如果它可以使用更大的类型进行优化;它只是保证他们至少需要 N 位。

The types int_fastN_t and uint_fastN_t are counterparts to the exact-width integer types intN_t and uintN_t. The implementation guarantees that they take at least N bits, but the implementation can take more bits if it can perform optimization using larger types; it just guarantees they take at least N bits.

例如,在32位机器上, uint_fast16_t 可以被定义为一个 unsigned int类型而不是一个无符号短因为类型的机器字长的工作会比较有效。

For example, on a 32-bit machine, uint_fast16_t could be defined as an unsigned int rather than as an unsigned short because working with types of machine word size would be more efficent.

他们的存在的另外一个原因是确切的宽度整数类型都是可选的C,但最快最小宽度整数类型和最小宽度整数类型( int_leastN_t uint_leastN_t )是必需的。

Another reason of their existence is the exact-width integer types are optional in C but the fastest minimum-width integer types and the minimum-width integer types (int_leastN_t and uint_leastN_t) are required.

这篇关于是什么intXX_t和int_fastXX_t之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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