+ 6
The basic idea is that -1 is not in the range of unsigned long and therefore a conversion is needed, producing the value code 1 printed. In code 2 you convert the value converted to unsigned long back to int (2 conversions, one in initialization and the other in printf()), resulting the same value -1.
27th Apr 2021, 12:51 PM
㊠æČč æˆ‘ć…ˆäž‹äș†
㊠æČč æˆ‘ć…ˆäž‹äș† - avatar
27th Apr 2021, 12:47 PM
Jan Markus
0
unsigned integers are nonnegative. assigning a negative to an unsigned variable causes undefined behavior Prince if you knew that, why ask?
27th Apr 2021, 12:44 PM
Slick
Slick - avatar