有符号字符转无符号字符
转换成二进制,取其补码即可
#include <iostream> using namespace std; int main() { signed char sc=-160; unsigned char uc=sc; cout<<(int)uc<<endl;//96 //10100000 160 //01011111 反码 //01100000 补码 96 system("pause"); return 0; }
运行结果:
转换成二进制,取其补码即可
#include <iostream> using namespace std; int main() { signed char sc=-160; unsigned char uc=sc; cout<<(int)uc<<endl;//96 //10100000 160 //01011111 反码 //01100000 补码 96 system("pause"); return 0; }
运行结果: