Why does this simple C program print -2147483648?
#include <stdio.h>
int main(){
printf("%i", (int)2147483648);
return 0;
}
Of course if I don’t cast it and use %lld as the format specifier I get the expected output.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When converting an integer to a smaller signed type, the behavior is implementation-defined if the value cannot be represented in the new type: