Different results between a 16-bit int machine and a 32-bit int machine in a subtraction
问题 When the code below is run against a 16-bit integer machine like MSP430 micro controller, s32 yields 65446 #include <stdint.h> uint16_t u16c; int32_t s32; int main() { u16c = 100U; s32 = 10 - u16c; } My understanding is that 10 - u16c gets implicit type promotion to unsigned int. Mathematically 10 - u16c equals to -90. But how is it possible to represent a negative number as an unsigned int? When -90 gets promoted to unsigned int, does it mean that the sign of a number is ignored? Lets