]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/test/math/rint.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / test / math / rint.c
1 #include <math.h>
2 #include <float.h>
3 #include <stdlib.h>
4 #include <stdint.h>
5 #include <stdio.h>
6
7 #define check_d1(func, param, expected) \
8 do { \
9         int err; hex_union ur; hex_union up; \
10         double result = func(param); up.f = param; ur.f = result; \
11         errors += (err = (result != (expected))); \
12         err \
13         ? printf("FAIL: %s(%g/"HEXFMT")=%g/"HEXFMT" (expected %g)\n", \
14                 #func, (double)(param), (long long)up.hex, result, (long long)ur.hex, (double)(expected)) \
15         : printf("PASS: %s(%g)=%g\n", #func, (double)(param), result); \
16 } while (0)
17
18 #define HEXFMT "%08llx"
19 typedef union {
20         double f;
21         uint64_t hex;
22 } hex_union;
23 double result;
24
25 int errors = 0;
26
27 int main(void)
28 {
29         check_d1(rint, 0.6, 1.0);
30
31         printf("Errors: %d\n", errors);
32         return errors;
33 }