int float double 最大值,最小值 2009-09-18 08:58 http://hi.baidu.com/cat_ng/blog/item/1131a4c2af0ea6120ef477db.html 1. 显示整型(int)的最小、最大值: #include
#include
int main(void) { int n1,n2; n1 = INT_MIN; n2 = INT_MAX; printf("%d .. %d", n1,n2); getchar(); return 0; } 2. 显示单精度类型(float)的最小、最大值: #include
#include
int main(void) { float f1 = FLT_MIN; float f2 = FLT_MAX; printf("%e .. %e ", f1,f2); getchar(); return 0; } 3. 显示双精度类型(double)的最小、最大值: #include
#include
int main(void) { double d1 = DBL_MIN; double d2 = DBL_MAX; printf("%e .. %e ", d1,d2); getchar(); return 0; } 附: /Microsoft Visual Studio/VC98/Include/LIMITS.H中定义的: #define MB_LEN_MAX 2 /* max. # bytes in multibyte char */ #define SHRT_MIN (-32768) /* minimum (signed) short value */ #define SHRT_MAX 32767 /* maximum (signed) short value */ #define USHRT_MAX 0xffff /* maximum unsigned short value */ #define INT_MIN (-2147483647 - 1) /* minimum (signed) int value */ #define INT_MAX 2147483647 /* maximum (signed) int value */ #define UINT_MAX 0xffffffff /* maximum unsigned int value */ #define LONG_MIN (-2147483647L - 1) /* minimum (signed) long value */ #define LONG_MAX 2147483647L /* maximum (signed) long value */ #define ULONG_MAX 0xffffffffUL /* maximum unsigned long value */ #if _INTEGRAL_MAX_BITS >= 8 #define _I8_MIN (-127i8 - 1) /* minimum signed 8 bit value */ #define _I8_MAX 127i8 /* maximum signed 8 bit value */ #define _UI8_MAX 0xffui8 /* maximum unsigned 8 bit value */ #endif #if _INTEGRAL_MAX_BITS >= 16 #define _I16_MIN (-32767i16 - 1) /* minimum signed 16 bit value */ #define _I16_MAX 32767i16 /* maximum signed 16 bit value */ #define _UI16_MAX 0xffffui16 /* maximum unsigned 16 bit value */ #endif #if _INTEGRAL_MAX_BITS >= 32 #define _I32_MIN (-2147483647i32 - 1) /* minimum signed 32 bit value */ #define _I32_MAX 2147483647i32 /* maximum signed 32 bit value */ #define _UI32_MAX 0xffffffffui32 /* maximum unsigned 32 bit value */ #endif #if _INTEGRAL_MAX_BITS >= 64 /* minimum signed 64 bit value */ #define _I64_MIN (-9223372036854775807i64 - 1) /* maximum signed 64 bit value */ #define _I64_MAX 9223372036854775807i64 /* maximum unsigned 64 bit value */ #define _UI64_MAX 0xffffffffffffffffui64 #endif #if _INTEGRAL_MAX_BITS >= 128 /* minimum signed 128 bit value */ #define _I128_MIN (-170141183460469231731687303715884105727i128 - 1) /* maximum signed 128 bit value */ #define _I128_MAX 170141183460469231731687303715884105727i128 /* maximum unsigned 128 bit value */ #define _UI128_MAX 0xffffffffffffffffffffffffffffffffui128 #endif /Microsoft Visual Studio/VC98/Include/FLOAT.H中定义: #define DBL_DIG 15 /* # of decimal digits of precision */ #define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */ #define DBL_MANT_DIG 53 /* # of bits in mantissa */ #define DBL_MAX 1.7976931348623158e+308 /* max value */ #define DBL_MAX_10_EXP 308 /* max decimal exponent */ #define DBL_MAX_EXP 1024 /* max binary exponent */ #define DBL_MIN 2.2250738585072014e-308 /* min positive value */ #define DBL_MIN_10_EXP (-307) /* min decimal exponent */ #define DBL_MIN_EXP (-1021) /* min binary exponent */ #define _DBL_RADIX 2 /* exponent radix */ #define _DBL_ROUNDS 1 /* addition rounding: near */ #define FLT_DIG 6 /* # of decimal digits of precision */ #define FLT_EPSILON 1.192092896e-07F /* smallest such that 1.0+FLT_EPSILON != 1.0 */ #define FLT_GUARD 0 #define FLT_MANT_DIG 24 /* # of bits in mantissa */ #define FLT_MAX 3.402823466e+38F /* max value */ #define FLT_MAX_10_EXP 38 /* max decimal exponent */ #define FLT_MAX_EXP 128 /* max binary exponent */ #define FLT_MIN 1.175494351e-38F /* min positive value */ #define FLT_MIN_10_EXP (-37) /* min decimal exponent */ #define FLT_MIN_EXP (-125) /* min binary exponent */ #define FLT_NORMALIZE 0 #define FLT_RADIX 2 /* exponent radix */ #define FLT_ROUNDS 1 /* addition rounding: near */ #ifndef _M_M68K #define LDBL_DIG DBL_DIG /* # of decimal digits of precision */ #define LDBL_EPSILON DBL_EPSILON /* smallest such that 1.0+LDBL_EPSILON != 1.0 */ #define LDBL_MANT_DIG DBL_MANT_DIG /* # of bits in mantissa */ #define LDBL_MAX DBL_MAX /* max value */ #define LDBL_MAX_10_EXP DBL_MAX_10_EXP /* max decimal exponent */ #define LDBL_MAX_EXP DBL_MAX_EXP /* max binary exponent */ #define LDBL_MIN DBL_MIN /* min positive value */ #define LDBL_MIN_10_EXP DBL_MIN_10_EXP /* min decimal exponent */ #define LDBL_MIN_EXP DBL_MIN_EXP /* min binary exponent */ #define _LDBL_RADIX DBL_RADIX /* exponent radix */ #define _LDBL_ROUNDS DBL_ROUNDS /* addition rounding: near */ #else #define LDBL_DIG 18 /* # of decimal digits of precision */ #define LDBL_EPSILON 1.08420217248550443412e-019L /* smallest such that 1.0+LDBL_EPSILON != 1.0 */ #define LDBL_MANT_DIG 64 /* # of bits in mantissa */ #define LDBL_MAX 1.189731495357231765e+4932L /* max value */ #define LDBL_MAX_10_EXP 4932 /* max decimal exponent */ #define LDBL_MAX_EXP 16384 /* max binary exponent */ #define LDBL_MIN 3.3621031431120935063e-4932L /* min positive value */ #define LDBL_MIN_10_EXP (-4931) /* min decimal exponent */ #define LDBL_MIN_EXP (-16381) /* min binary exponent */ #define _LDBL_RADIX 2 /* exponent radix */ #define _LDBL_ROUNDS 1 /* addition rounding: near */ #endif
int float double 最值
最新推荐文章于 2022-10-03 23:27:16 发布