I am confused by how type promotion occurs in the case of printf and in general. I tried the following code
unsigned char uc = 255
signed char sc = -128
printf("unsigned char value = %d \n", uc);
printf("signed char value = %d \n", sc);
This gives the following result:
unsigned char value = 255
signed char value = -128
This made me think about how it really is progressing and whether the sign is expanding or not. If the expansion of the mark is completed, the value 255 should be printed as a negative value (-128, remaining the same), and if the expansion without a mark was not performed, then -128 should be printed as a positive value (255 remained the same). Explain, please.
source
share