Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
int16_t s; uint32_t ui = s;
将值转换为int16_t值uint32_t编译器的结果是否取决于?如果不是,规则是什么?
int16_t
uint32_t
结果明确;非负值保持不变,负值以 2^32 为模减少。但是需要精确大小的类型int16_t的情况uint32_t很少见。int除了和这里真的不需要任何东西unsigned long:这些类型至少有和和一样多的位,int16_t与anduint32_t不同,它们必须存在于任何符合要求的实现中。如果你真的想要性感的新尺寸类型,至少要使用 和 的便携性。int16_tuint32_tint_least16_tuint_least32_t
int
unsigned long
int_least16_t
uint_least32_t