テストタイプ範囲値

1732 ワード

#include <stdio.h>
#include <limits.h>

int main()
{
     printf( "sizeof(short)=%d,  max short int is: %ld
", sizeof(short), SHRT_MAX ); printf( "sizeof(int)=%d, max int is: %ld
", sizeof(int), INT_MAX); printf( "sizeof(long)=%d, max long int is: %ld
", sizeof(long), LONG_MAX ); return 0; }
 :
sizeof(short)=2,  max short int is: 32767
sizeof(int)=4,    max int is: 2147483647
sizeof(long)=8,   max long int is: 9223372036854775807
 
#  define CHAR_BIT	8
#  define SCHAR_MIN	(-128)
#  define SCHAR_MAX	127
#  define UCHAR_MAX	255

#  ifdef __CHAR_UNSIGNED__
#   define CHAR_MIN	0
#   define CHAR_MAX	UCHAR_MAX
#  else
#   define CHAR_MIN	SCHAR_MIN
#   define CHAR_MAX	SCHAR_MAX
#  endif

#  define SHRT_MIN	(-32768)
#  define SHRT_MAX	32767
#  define USHRT_MAX	65535
#  define INT_MIN	(-INT_MAX - 1)
#  define INT_MAX	2147483647
#  define UINT_MAX	4294967295U

#  if __WORDSIZE == 64
#   define LONG_MAX	9223372036854775807L
#  else
#   define LONG_MAX	2147483647L
#  endif
#  define LONG_MIN	(-LONG_MAX - 1L)

#  if __WORDSIZE == 64
#   define ULONG_MAX	18446744073709551615UL
#  else
#   define ULONG_MAX	4294967295UL
#  endif

#  ifdef __USE_ISOC99
#   define LLONG_MAX	9223372036854775807LL
#   define LLONG_MIN	(-LLONG_MAX - 1LL)
#   define ULLONG_MAX	18446744073709551615ULL