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

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






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