標(biāo)題: c語(yǔ)言 整型數(shù)據(jù)的溢出 [打印本頁(yè)]

作者: liuda    時(shí)間: 2015-1-22 02:59
標(biāo)題: c語(yǔ)言 整型數(shù)據(jù)的溢出
#include<stdio.h>/*整型數(shù)據(jù)的溢出*/
void main()
{
int a,b;
a=2147483647;/*2^31-1,看來(lái)在visual c中int型變量的最大允許值是214783647*/
b=a+1;/*本來(lái)最高位是符號(hào)位是0,加了1之后最高位是0,變成負(fù)數(shù),-214783648的補(bǔ)碼*/
printf("a=%db=%d\n",a,b);
}






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1