トップ 差分 一覧 ソース 置換 検索 ヘルプ PDF RSS ログイン

C言語の数値の最大、最小値

http://d.hatena.ne.jp/rero/20071208/p1

cygwin で
-mno-cygwin を付けるときは、long long に注意

%lld

ではなく

%I64d

を使う。

 // gcc -O2 -Os -mno-cygwin test.cpp
 
 /* max.c */
 
 #include <stdio.h>
 #include <limits.h>
 
 int main()
 {
   printf("char size: %d\n", CHAR_BIT);
   printf("char max: %d\n", CHAR_MAX);
   printf("char min: %d\n", CHAR_MIN);
   printf("int max: %d\n", INT_MAX);
   printf("int min: %d\n", INT_MIN);
   printf("long max: %ld\n", LONG_MAX);
   printf("long min: %ld\n", LONG_MIN);
   printf("long long max: %lld\n", LLONG_MAX);
   printf("long long min: %lld\n", LLONG_MIN);
   
   printf("long long max: %I64d\n", LLONG_MAX);
   printf("long long min: %I64d\n", LLONG_MIN);
   
   printf("singed char max: %d\n", SCHAR_MAX);
   printf("signed char min: %d\n", SCHAR_MIN);
   printf("short max: %d\n", SHRT_MAX);
   printf("short min: %d\n", SHRT_MIN);
   printf("unsigned char max: %d\n", UCHAR_MAX);
   printf("unsigned int max: %u\n", UINT_MAX);
   printf("unsigned long max: %lu\n", ULONG_MAX);
   printf("unsigned short max: %lu\n", USHRT_MAX);
   printf("unsigned long long max: %llu\n", ULLONG_MAX);
 
   return 0;
 }

[カテゴリ: プログラミング言語 > C]

[通知用URL]



  • Hatenaブックマークに追加
  • livedoorクリップに追加
  • del.icio.usに追加
  • FC2ブックマークに追加

最終更新時間:2011年07月22日 20時40分00秒