[c]代码库
/* 检查各浮点型可存储的数量级范围 */
#include <stdio.h>
int main(void) {
float f_max = 1.123e38f; /* 可以不使用f后缀,但可能会出现warning */
float f_min = -1.123e38f;
float f_max_e = 1.123e39f;
float f_min_e = -1.123e39f;
double d_max = 1.123e308;
double d_min = -1.123e308;
double d_max_e = 1.123e309;
double d_min_e = -1.123e309;
long double ld_max = 1.123e4932l; /* 必须使用后缀l或L */
long double ld_min = -1.123e4932l;
long double ld_max_e = 1.123e4933l;
long double ld_min_e = -1.123e4933l;
/* 验证float型的数量级范围 */
printf("f_max = %f\n", f_max);
printf("f_min = %f\n", f_min);
printf("f_max_e = %f\n", f_max_e);
printf("f_min_e = %f\n", f_min_e);
/* 验证double型的数量级范围 */
printf("d_max = %lf\n", d_max);
printf("d_min = %lf\n", d_min);
printf("d_max_e = %lf\n", d_max_e);
printf("d_min_e = %lf\n", d_min_e);
/* 验证long double型的数量级范围 */
printf("ld_max = %llf\n", ld_max);
printf("ld_min = %llf\n", ld_min);
printf("ld_max_e = %llf\n", ld_max_e);
printf("ld_min_e = %llf\n", ld_min_e);
return 0;
}
by: 发表于:2017-08-15 10:50:49 顶(0) | 踩(0) 回复
??
回复评论