What is uint_fast32_t and why should it be used instead of the regular int and uint32_t?(什么是 uint_fast32_t,为什么要使用它而不是常规的 int 和 uint32_t?)
问题描述
所以 typedef:ed 原始数据类型的原因是为了抽象低级表示并使其更容易理解(uint64_t 而不是 long long 类型,即 8 个字节).
So the reason for typedef:ed primitive data types is to abstract the low-level representation and make it easier to comprehend (uint64_t instead of long long type, which is 8 bytes). 
但是,uint_fast32_t 与 uint32_t 具有相同的 typedef.使用快速"版本会使程序更快吗?
However, there is uint_fast32_t which has the same typedef as uint32_t. Will using the "fast" version make the program faster?
推荐答案
int在某些平台上可能小到 16 位.它可能不足以满足您的应用需求.uint32_t不保证存在.它是一个可选的typedef,如果它具有恰好 32 位的无符号整数类型,则实现必须提供它.例如,有些具有 9 位字节,因此它们没有uint32_t.uint_fast32_t清楚地说明了您的意图:这是一种至少 32 位的类型,从性能的角度来看是最好的.uint_fast32_t实际上可能是 64 位长.这取决于实施.intmay be as small as 16 bits on some platforms. It may not be sufficient for your application.uint32_tis not guaranteed to exist. It's an optionaltypedefthat the implementation must provide iff it has an unsigned integer type of exactly 32-bits. Some have a 9-bit bytes for example, so they don't have auint32_t.uint_fast32_tstates your intent clearly: it's a type of at least 32 bits which is the best from a performance point-of-view.uint_fast32_tmay be in fact 64 bits long. It's up to the implementation.标准委员会关心的异国架构.
... 有 uint_fast32_t 与 uint32_t 具有相同的 typedef ...
... there is
uint_fast32_twhich has the same typedef asuint32_t...
你看的不是标准.这是一个特定的实现(黑莓).所以你不能从那里推断出 uint_fast32_t 总是与 uint32_t 相同.
What you are looking at is not the standard. It's a particular implementation (BlackBerry). So you can't deduce from there that uint_fast32_t is always the same as uint32_t.
另见:
我对 C 和 C++ 中整数类型的基于意见的实用观点.
这篇关于什么是 uint_fast32_t,为什么要使用它而不是常规的 int 和 uint32_t?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么是 uint_fast32_t,为什么要使用它而不是常规的 int 和 uint32_t?
				
        
 
            
        - 使用/clr 时出现 LNK2022 错误 2022-01-01
 - 近似搜索的工作原理 2021-01-01
 - 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
 - 如何对自定义类的向量使用std::find()? 2022-11-07
 - C++ 协变模板 2021-01-01
 - STL 中有 dereference_iterator 吗? 2022-01-01
 - 从python回调到c++的选项 2022-11-16
 - 静态初始化顺序失败 2022-01-01
 - Stroustrup 的 Simple_window.h 2022-01-01
 - 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
 
						
						
						
						
						
				
				
				
				