//p28.c -- @CopyLeft by tsaiwn@csie.nctu.edu.tw // demo the strange of Integer because of 2's complement // Most computers use 2's complement to represent negative numbers #include int main( ) { short gg, ans = 32765; int k; for(k=1; k<= 6; ++k) { printf ("= %hd ", ans ); gg = -ans; if(gg == ans) printf("=YES\n"); else printf("=NO\n"); ans++; } // for k printf("Hit RETURN key..."); getchar( ); return 0; } /****** C:\test2> gcc p28.c C:\test2> a.exe = 32765 =NO = 32766 =NO = 32767 =NO = -32768 =YES = -32767 =NO = -32766 =NO C:\test2> ********************/