int,long,short,float,double的大小
/*********************************************** * * 判断int,long,short,float,double的大小 * by zhaozhilu * *********************************************** */ #include<stdio.h> #include<math.h> int main() { int a,i; long int b; short int c; float d; double e; printf("整型是%d字节\n",sizeof(a)); i=sizeof(a)*8; printf("整型的最大值是%f\n",pow(2,i)); printf("长整型是%d字节\n",sizeof(b)); i=sizeof(b)*8; printf("长整型的最大值是%f\n",pow(2,i)); printf("短整型是%d字节\n",sizeof(c)); i=sizeof(c)*8; printf("短整型的最大值是%f\n",pow(2,i)); printf("浮点型是%d字节\n",d); i=sizeof(d)*8; printf("浮点型的最大值是%f\n",pow(2,i)); printf("双精度型是%d字节\n",sizeof(e)); i=sizeof(e)*8; printf("双精度型的最大值是%f\n",pow(2,i)); return 0; }
编译的时候要链接math库:gcc test.c -lm