Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - printf("%d ",0x 7 fdffffff); Why is it printed as a negative number?
printf("%d ",0x 7 fdffffff); Why is it printed as a negative number?
Data overflow, because %d is a printed integer, the integer range of C language is-2147483648 ~ 2147483647, and the hexadecimal number 7fdffffff is equivalent to the decimal number 343 183935, so the printed number is negative.

Change %d to %ld to print long integers, so that the data will not overflow and print negative numbers.

The complete C language program is as follows

# include & ltstdio.h & gt

int main()

{

printf("%ld ",0x 7 fdffffff);

Returns 0;

}