Assuming I have 2 variables:
假设我有2个变量:
uint64_t a = ...
uint32_t b = ...
Will comparing the integers yield the expected results, i.e. (a != b)
, or (b > a)
?
比较整数会产生预期的结果,即(a!= b),还是(b> a)?
2 个解决方案
#1
20
No problem. The compiler promotes the 32-bit to 64-bit before the comparison
没问题。编译器在比较之前将32位升级到64位
#2
8
Short answer - yes. The 'smaller' is converted to bigger one before comparison.
简短的回答 - 是的。在比较之前,'较小'将转换为较大的一个。
#1
20
No problem. The compiler promotes the 32-bit to 64-bit before the comparison
没问题。编译器在比较之前将32位升级到64位
#2
8
Short answer - yes. The 'smaller' is converted to bigger one before comparison.
简短的回答 - 是的。在比较之前,'较小'将转换为较大的一个。