今天在做POJ的题是遇到了大数问题,就想编程支持long的最大值范围。
long max = 1;
printf("sizeof(long ) = %d \n",sizeof(long)); //long类型数据占的字节数bytes
printf("sizeof(int ) = %d \n",sizeof(int));
printf("sizeof(long long ) = %d \n",sizeof(long long));
printf("Max of long is %ld \n",~(max<<(sizeof(long)*8-1)));//long 的最大值
printf("Min of long is %ld \n",(max<<(sizeof(long)*8-1))); //long 的最小值