An implicit type conversion! Ask God to answer

#include <iostream>

using namespace std;

int main()
{
 unsigned char a = 0xA5;
 unsigned char b = ~a >> 4 + 1;
 printf("b = %d\n", b);
 return 0;
}



At the interview, I don't understand the answer to this question, who can help explain some of the details?

Started by Edmund at November 17, 2016 - 10:03 AM

Type promotion, c/c++ standard, is provided.

Posted by Oscar at November 23, 2016 - 10:36 AM

I don't understand the value of the a 8 inside the inverse 1111111101011010 in front of it comes out more details of what is?

Posted by Edmund at December 02, 2016 - 11:20 AM

 printf("b = %d\n", b);

Change
printf("b = %hhd\n", b);

Posted by Jessee at December 15, 2016 - 12:19 PM