【发布时间】:2014-05-30 15:30:26
【问题描述】:
我阅读了很多关于最快最小宽度整数类型的解释,但我不明白何时使用这些数据类型。
我的理解: 在 32 位机器上,
uint_least16_t 可以 typedef 为一个无符号的 short。
1. uint_least16_t small = 38;
2. unsigned short will be of 16 bits so the value 38 will be stored using 16 bits. And this will take up 16 bits of memory.
3. The range for this data type will be 0 to (2^N)-1 , here N=16.
uint_fast16_t 可以是无符号整数的 typedef。
1. uint_fast16_t fast = 38;
2. unsigned int will be of 32 bits so the value 38 will be stored using 32 bits. And this will take up 32 bits of memory.
3. what will be the range for this data type ?
uint_fast16_t => uint_fastN_t , here N = 16
but the value can be stored in 32 bits so IS it 0 to (2^16)-1 OR 0 to (2^32)-1 ?
how can we make sure that its not overflowing ?
Since its a 32 bit, Can we assign >65535 to it ?
If it is a signed integer, how signedness is maintained.
For example int_fast16_t = 32768;
since the value falls within the signed int range, it'll be a positive value.
【问题讨论】:
标签: c memory c99 unsigned signed