/******************************
* file: type.c
* date: 2008-04-20
* desc:
* 显示各个有符号整型的长度及范围
* ***************************/
#include<stdio.h>
int main(int argc,char *argv[])
{
char c_begin,c_end;
c_begin = 1L << (sizeof(char)*8 - 1);
c_end = ~c_begin;
printf("# char -- %d位%d字节,表示范围 %d ~ %d /n",sizeof(char)*8,sizeof(char),c_begin,c_end);
int i_begin,i_end;
i_begin = 1L << (sizeof(int)*8 - 1);
i_end = ~i_begin;
printf("# int -- %d位%d字节,表示范围 %d ~ %d/n",sizeof(int)*8,sizeof(int),i_begin,i_end);
long l_begin,l_end;
l_begin = 1L << (sizeof(long)*8 - 1);
l_end = ~l_begin;
printf("# long -- %d位%d字节,表示范围 %d ~ %d/n",sizeof(long)*8,sizeof(long),l_begin,l_end);
return 0;
}
(有符号)整形的大小及表示范围
最新推荐文章于 2023-08-06 11:03:16 发布