-PROGS=proffenv profmath realgen testrand
+PROGS=proffenv profmath realgen testrand testrand2
ALL: $(PROGS)
# -Wstrict-prototypes
testrand: testrand.c ../subr_random.c
$(CC99) $(CCFLAGS) $(INCLUDE) \
testrand.c ../subr_random.c \
- -o testrand \
- $(LIB)
+ -o testrand -lm
+
+testrand2: testrand2.c ../subr_random.c
+ $(CC99) $(CCFLAGS) $(INCLUDE) \
+ testrand2.c ../subr_random.c \
+ -o testrand2 -lm
gen-csv: profmath
#include <assert.h>
#include <math.h>
+#include <mytypes.h>
#include <stdio.h>
#include <string.h>
stats {
const char *st_type;
size_t st_normals;
- size_t st_denormals;
+ size_t st_subnormals;
size_t st_nans;
size_t st_inf;
size_t st_zero;
st->st_type = #type; \
\
for (i = 0; i < N; i++) { \
- x = random_##type(0); \
- \
+ x = random_##type(1); \
switch (fpclassify(x)) { \
case FP_NORMAL: \
- st->st_normals++; \
+ ++st->st_normals; \
break; \
case FP_SUBNORMAL: \
- st->st_denormals++; \
+ ++st->st_subnormals; \
break; \
case FP_NAN: \
- st->st_nans++; \
+ ++st->st_nans; \
break; \
case FP_INFINITE: \
- st->st_inf++; \
+ ++st->st_inf; \
break; \
case FP_ZERO: \
- st->st_zero++; \
+ ++st->st_zero; \
break; \
default: \
/* invalid floating-point number */ \
- st->st_invalid++; \
+ ++st->st_invalid; \
break; \
} \
} \
printf("---------- %s ----------\n", st->st_type);
printf(" Normals: %u\n", st->st_normals);
- printf("Denormals: %u\n", st->st_denormals);
+ printf("Subnormals: %u\n", st->st_subnormals);
printf(" NaNs: %u\n", st->st_nans);
printf(" Inf: %u\n", st->st_inf);
printf(" Zero: %u\n", st->st_zero);
main(void)
{
struct stats s;
- const size_t N = 1*1000*1000;
+ const size_t N = 100*1000*1000;
+ init_randgen();
+#if 0
/* floats */
probe_float(&s, N);
print_stats(&s);
/* double */
probe_double(&s, N);
print_stats(&s);
+#endif
/* long double */
probe_long_double(&s, N);
#define MY_FP_ZERO 0x10
#define MY_FP_REAL (MY_FP_NORMAL | MY_FP_SUBNORMAL | MY_FP_ZERO)
+#define MY_FP_ALL (MY_FP_NORMAL | MY_FP_SUBNORMAL | MY_FP_ZERO \
+ | MY_FP_INFINITE | MY_FP_ZERO)
#endif /* ! __MY_TYPES__ */
do {
for (i = 0; i < NQUADS; i++)
u.y[i] = MY_RANDOM();
- } while (!ISVALIDFP(u.y) || ((fpclassify(u.x)) != fpclass));
+ } while (!ISVALIDFP(u.y));
return (u.x);
}