floating: Add remainder functions.
[altfloat.git] / cfloat.c
blob89c607bdcb108c300d261c58db0cf23acdf49853
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <math.h>
6 #include "cfloat.h"
8 int double_format(char *buf, const char *fmt, double val)
10 if (buf == NULL)
11 return snprintf(NULL, 0, fmt, val);
12 return sprintf(buf, fmt, val);
15 double double_signum(double val)
17 if (signbit(val))
18 return -1;
19 return 1;
22 int double_classify(double val)
24 switch (fpclassify(val)) {
25 case FP_INFINITE:
26 return 0;
27 case FP_NAN:
28 return 1;
29 case FP_NORMAL:
30 return 2;
31 case FP_SUBNORMAL:
32 return 3;
33 case FP_ZERO:
34 return 4;
37 return -1;