blob: fc3e41cbe07e7c42295d1e0067713d22e8ef0192 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001#ifndef __DD_HEADER
2#define __DD_HEADER
3
4#include "../int_lib.h"
5
6typedef union {
7 long double ld;
8 struct {
9 double hi;
10 double lo;
11 }s;
12}DD;
13
14typedef union {
15 double d;
16 uint64_t x;
17} doublebits;
18
19#define LOWORDER(xy,xHi,xLo,yHi,yLo) \
20 (((((xHi)*(yHi) - (xy)) + (xHi)*(yLo)) + (xLo)*(yHi)) + (xLo)*(yLo))
21
22static inline double __attribute__((always_inline))
23local_fabs(double x)
24{
25 doublebits result = { .d = x };
26 result.x &= UINT64_C(0x7fffffffffffffff);
27 return result.d;
28}
29
30static inline double __attribute__((always_inline))
31high26bits(double x)
32{
33 doublebits result = { .d = x };
34 result.x &= UINT64_C(0xfffffffff8000000);
35 return result.d;
36}
37
38static inline int __attribute__((always_inline))
39different_sign(double x, double y)
40{
41 doublebits xsignbit = { .d = x }, ysignbit = { .d = y };
42 int result = (int)(xsignbit.x >> 63) ^ (int)(ysignbit.x >> 63);
43 return result;
44}
45
46#endif /* __DD_HEADER */