I was expecting this to print a very large number and that same number -1 but it just prints -1 and -2, why is this?
fprintf(stderr, "%d\n", 0xffffffff);
fprintf(stderr, "%d\n", 0xfffffffe);
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.
The
%dformat is a signed integer (decimal). Integers are stored using two’s complement, which means that the high-order bit (8000 0000) indicates, in a manner of speaking, the sign of the value.Counting down from 3, values are:
etc.
If you want FFFF FFFF to display as a large positive number, use the
%u(unsigned) format.