2022-06-11 04:49:07 +00:00
|
|
|
|
2022-08-06 12:36:16 +00:00
|
|
|
#include <std.h>
|
2022-06-11 04:49:07 +00:00
|
|
|
|
2022-08-07 06:24:37 +00:00
|
|
|
double cool_doubles[] = {
|
|
|
|
-NAN,
|
|
|
|
-INFINITY,
|
|
|
|
-DBL_MAX,
|
|
|
|
-2.7,
|
|
|
|
-2.5,
|
|
|
|
-2.3,
|
|
|
|
-1.0,
|
|
|
|
-DBL_TRUE_MIN,
|
|
|
|
-DBL_MIN,
|
|
|
|
-0.0,
|
|
|
|
+0.0,
|
|
|
|
DBL_MIN,
|
|
|
|
DBL_TRUE_MIN,
|
|
|
|
1.0,
|
|
|
|
2.3,
|
|
|
|
2.5,
|
|
|
|
2.7,
|
|
|
|
DBL_MAX,
|
|
|
|
INFINITY,
|
|
|
|
NAN,
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t ncool_doubles = COUNTOF(cool_doubles);
|
|
|
|
|
|
|
|
#define for_each_cool_double(i,d,b) \
|
|
|
|
for(int i = 0; i != ncool_doubles; ++i) { \
|
|
|
|
double d = cool_doubles[i]; \
|
|
|
|
b; \
|
|
|
|
}
|
|
|
|
|
2022-06-11 04:49:07 +00:00
|
|
|
const char *show_classification(double x) {
|
|
|
|
switch(fpclassify(x)) {
|
|
|
|
case FP_INFINITE: return "Inf";
|
|
|
|
case FP_NAN: return "NaN";
|
|
|
|
case FP_NORMAL: return "normal";
|
|
|
|
case FP_SUBNORMAL: return "subnormal";
|
|
|
|
case FP_ZERO: return "zero";
|
|
|
|
default: return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2022-08-07 06:24:37 +00:00
|
|
|
for(int i = 0; i != ncool_doubles; ++i) {
|
|
|
|
double d = cool_doubles[i];
|
|
|
|
printf("%a\n", d);
|
|
|
|
}
|
2022-06-11 04:49:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|