バイナリデータを扱うようになって意識するようになったのでメモ
#include
#include
int main(int argc,char **argv){
printf("size of char: %d bit\n",CHAR_BIT);
printf(" char range is %d -> %d\n",CHAR_MIN,CHAR_MAX);
printf(" signed char range is %d -> %d\n",SCHAR_MIN,SCHAR_MAX);
printf("unsigned char range is 0 -> %u\n",UCHAR_MAX);
printf(" int range is %d -> %d\n",INT_MIN,INT_MAX);
printf("unsigned int range is 0 -> %u\n",UINT_MAX);
printf(" short range is %d -> %d\n",SHRT_MIN,SHRT_MAX);
printf("unsigned short range is 0 -> %u\n",USHRT_MAX);
printf(" long range is %ld -> %ld\n",LONG_MIN,LONG_MAX);
printf("unsigned long range is 0 -> %lu\n",ULONG_MAX);
return 0;
}
以下がi386環境での実行結果
size of char: 8 bit
char range is -128 -> 127
signed char range is -128 -> 127
unsigned char range is 0 -> 255
int range is -2147483648 -> 2147483647
unsigned int range is 0 -> 4294967295
short range is -32768 -> 32767
unsigned short range is 0 -> 65535
long range is -2147483648 -> 2147483647
unsigned long range is 0 -> 4294967295
以下がamd64環境での実行結果
size of char: 8 bit
char range is -128 -> 127
signed char range is -128 -> 127
unsigned char range is 0 -> 255
int range is -2147483648 -> 2147483647
unsigned int range is 0 -> 4294967295
short range is -32768 -> 32767
unsigned short range is 0 -> 65535
long range is -9223372036854775808 -> 9223372036854775807
unsigned long range is 0 -> 18446744073709551615
0 件のコメント:
コメントを投稿