unsigned int与int相加的问题-----C/C++小知识 区别


http://blog.csdn.net/thefutureisour/article/details/8147277

 

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
unsigned int a=32;

int b=-6;

unsigned int c=a+b;        //把b转化为unsigned int   0xfffffffa +   0x00000020 ----->26(十进制)    //-6补码被当成一个无符号数

 

printf("%u",c);


}

 

c      0x0000001a         unsigned int

b      0xfffffffa               int

a      0x00000020        unsigned int

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM