// filename:c2011-5-2-4-2-2-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf // C2011 5.2.4.2.2 Characteristics of floating types // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, January.4, 2014 // compile errors and/or wornings: // 1 (c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn) // Target: x86_64-apple-darwin11.4.2 //Thread model: posix // (c) LLVM 2003-2009 University of Illinois at Urbana-Champaign. // 2 gcc-4.9 (GCC) 4.9.0 20131229 (experimental) // Copyright (C) 2013 Free Software Foundation, Inc. #include #include #include #define PRD(X,Y) printf(#X"=%d %d, %d \n",X,Y,X==Y); #define PRF(X,Y) printf(#X"=%e %e, %d \n",X,Y,X==Y); int main(void){ PRD(FLT_RADIX, 16); PRD(FLT_MANT_DIG,6); PRF(FLT_EPSILON,9.53674316E-07F) PRD(FLT_DECIMAL_DIG,9); PRD(FLT_DIG ,6); PRD(FLT_MIN_EXP, -31) PRF(FLT_MIN, 2.93873588E-39F) PRD(FLT_MIN_10_EXP, -38) PRD(FLT_MAX_EXP, +32) PRF(FLT_MAX, 3.40282347E+38F) PRD(FLT_MAX_10_EXP, +38) PRD(FLT_RADIX, 2) PRD(DECIMAL_DIG, 17) PRD(FLT_MANT_DIG, 24) PRF(FLT_EPSILON, 1.19209290E-07F) // decimal constant PRF(FLT_EPSILON, 0X1P-23F) // hex constant PRD(FLT_DECIMAL_DIG, 9) PRD(FLT_DIG, 6) PRD(FLT_MIN_EXP, -125) PRF(FLT_MIN, 1.17549435E-38F) // decimal constant PRF(FLT_MIN, 0X1P-126F) // hex constant PRF(FLT_TRUE_MIN, 1.40129846E-45F) // decimal constant PRF(FLT_TRUE_MIN, 0X1P-149F) // hex constant PRD(FLT_HAS_SUBNORM, 1) PRD(FLT_MIN_10_EXP, -37) PRD(FLT_MAX_EXP, +128) PRF(FLT_MAX, 3.40282347E+38F) // decimal constant PRF(FLT_MAX, 0X1.fffffeP127F) // hex constant PRD(FLT_MAX_10_EXP, +38) PRD(DBL_MANT_DIG, 53) PRF(DBL_EPSILON, 2.2204460492503131E-16) // decimal constant PRF(DBL_EPSILON, 0X1P-52) // hex constant PRD(DBL_DECIMAL_DIG, 17) PRD(DBL_DIG, 15) PRD(DBL_MIN_EXP, -1021) PRF(DBL_MIN, 2.2250738585072014E-308) // decimal constant PRF(DBL_MIN, 0X1P-1022) // hex constant PRF(DBL_TRUE_MIN, 4.9406564584124654E-324) // decimal constant PRF(DBL_TRUE_MIN, 0X1P-1074) // hex constant PRD(DBL_HAS_SUBNORM, 1) PRD(DBL_MIN_10_EXP, -307) PRD(DBL_MAX_EXP, +1024) PRF(DBL_MAX, 1.7976931348623157E+308) // decimal constant PRF(DBL_MAX, 0X1.fffffffffffffP1023) // hex constant PRD(DBL_MAX_10_EXP, +308) printf("\n5.2.4.2.2 Characteristics of floating types \n"); } // output may be //FLT_RADIX=2 16, 0 //FLT_MANT_DIG=24 6, 0 //FLT_EPSILON=1.192093e-07 9.536743e-07, 0 //FLT_DECIMAL_DIG=9 9, 1 //FLT_DIG=6 6, 1 //FLT_MIN_EXP=-125 -31, 0 //FLT_MIN=1.175494e-38 2.938736e-39, 0 //FLT_MIN_10_EXP=-37 -38, 0 //FLT_MAX_EXP=128 32, 0 //FLT_MAX=3.402823e+38 3.402823e+38, 1 //FLT_MAX_10_EXP=38 38, 1 //FLT_RADIX=2 2, 1 //DECIMAL_DIG=21 17, 0 //FLT_MANT_DIG=24 24, 1 //FLT_EPSILON=1.192093e-07 1.192093e-07, 1 //FLT_EPSILON=1.192093e-07 1.192093e-07, 1 //FLT_DECIMAL_DIG=9 9, 1 //FLT_DIG=6 6, 1 //FLT_MIN_EXP=-125 -125, 1 //FLT_MIN=1.175494e-38 1.175494e-38, 1 //FLT_MIN=1.175494e-38 1.175494e-38, 1 //FLT_TRUE_MIN=1.401298e-45 1.401298e-45, 1 //FLT_TRUE_MIN=1.401298e-45 1.401298e-45, 1 //FLT_HAS_SUBNORM=1 1, 1 //FLT_MIN_10_EXP=-37 -37, 1 //FLT_MAX_EXP=128 128, 1 //FLT_MAX=3.402823e+38 3.402823e+38, 1 //FLT_MAX=3.402823e+38 3.402823e+38, 1 //FLT_MAX_10_EXP=38 38, 1 //DBL_MANT_DIG=53 53, 1 //DBL_EPSILON=2.220446e-16 2.220446e-16, 1 //DBL_EPSILON=2.220446e-16 2.220446e-16, 1 //DBL_DECIMAL_DIG=17 17, 1 //DBL_DIG=15 15, 1 //DBL_MIN_EXP=-1021 -1021, 1 //DBL_MIN=2.225074e-308 2.225074e-308, 1 //DBL_MIN=2.225074e-308 2.225074e-308, 1 //DBL_TRUE_MIN=4.940656e-324 4.940656e-324, 1 //DBL_TRUE_MIN=4.940656e-324 4.940656e-324, 1 //DBL_HAS_SUBNORM=1 1, 1 //DBL_MIN_10_EXP=-307 -307, 1 //DBL_MAX_EXP=1024 1024, 1 //DBL_MAX=1.797693e+308 1.797693e+308, 1 //DBL_MAX=1.797693e+308 1.797693e+308, 1 //DBL_MAX_10_EXP=308 308, 1