1 | #include <ansidecl.h>
|
---|
2 |
|
---|
3 | #ifdef __IEEE_BIG_ENDIAN
|
---|
4 |
|
---|
5 | typedef union
|
---|
6 | {
|
---|
7 | double value;
|
---|
8 | struct
|
---|
9 | {
|
---|
10 | unsigned int sign : 1;
|
---|
11 | unsigned int exponent: 11;
|
---|
12 | unsigned int fraction0:4;
|
---|
13 | unsigned int fraction1:16;
|
---|
14 | unsigned int fraction2:16;
|
---|
15 | unsigned int fraction3:16;
|
---|
16 |
|
---|
17 | } number;
|
---|
18 | struct
|
---|
19 | {
|
---|
20 | unsigned int sign : 1;
|
---|
21 | unsigned int exponent: 11;
|
---|
22 | unsigned int quiet:1;
|
---|
23 | unsigned int function0:3;
|
---|
24 | unsigned int function1:16;
|
---|
25 | unsigned int function2:16;
|
---|
26 | unsigned int function3:16;
|
---|
27 | } nan;
|
---|
28 | struct
|
---|
29 | {
|
---|
30 | unsigned long msw;
|
---|
31 | unsigned long lsw;
|
---|
32 | } parts;
|
---|
33 | long aslong[2];
|
---|
34 | } __ieee_double_shape_type;
|
---|
35 |
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #ifdef __IEEE_LITTLE_ENDIAN
|
---|
39 |
|
---|
40 | typedef union
|
---|
41 | {
|
---|
42 | double value;
|
---|
43 | struct
|
---|
44 | {
|
---|
45 | #ifdef __SMALL_BITFIELDS
|
---|
46 | unsigned int fraction3:16;
|
---|
47 | unsigned int fraction2:16;
|
---|
48 | unsigned int fraction1:16;
|
---|
49 | unsigned int fraction0: 4;
|
---|
50 | #else
|
---|
51 | unsigned int fraction1:32;
|
---|
52 | unsigned int fraction0:20;
|
---|
53 | #endif
|
---|
54 | unsigned int exponent :11;
|
---|
55 | unsigned int sign : 1;
|
---|
56 | } number;
|
---|
57 | struct
|
---|
58 | {
|
---|
59 | #ifdef __SMALL_BITFIELDS
|
---|
60 | unsigned int function3:16;
|
---|
61 | unsigned int function2:16;
|
---|
62 | unsigned int function1:16;
|
---|
63 | unsigned int function0:3;
|
---|
64 | #else
|
---|
65 | unsigned int function1:32;
|
---|
66 | unsigned int function0:19;
|
---|
67 | #endif
|
---|
68 | unsigned int quiet:1;
|
---|
69 | unsigned int exponent: 11;
|
---|
70 | unsigned int sign : 1;
|
---|
71 | } nan;
|
---|
72 | struct
|
---|
73 | {
|
---|
74 | unsigned long lsw;
|
---|
75 | unsigned long msw;
|
---|
76 | } parts;
|
---|
77 |
|
---|
78 | long aslong[2];
|
---|
79 |
|
---|
80 | } __ieee_double_shape_type;
|
---|
81 |
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | #ifdef __IEEE_BIG_ENDIAN
|
---|
85 | typedef union
|
---|
86 | {
|
---|
87 | float value;
|
---|
88 | struct
|
---|
89 | {
|
---|
90 | unsigned int sign : 1;
|
---|
91 | unsigned int exponent: 8;
|
---|
92 | unsigned int fraction0: 7;
|
---|
93 | unsigned int fraction1: 16;
|
---|
94 | } number;
|
---|
95 | struct
|
---|
96 | {
|
---|
97 | unsigned int sign:1;
|
---|
98 | unsigned int exponent:8;
|
---|
99 | unsigned int quiet:1;
|
---|
100 | unsigned int function0:6;
|
---|
101 | unsigned int function1:16;
|
---|
102 | } nan;
|
---|
103 | long p1;
|
---|
104 |
|
---|
105 | } __ieee_float_shape_type;
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | #ifdef __IEEE_LITTLE_ENDIAN
|
---|
109 | typedef union
|
---|
110 | {
|
---|
111 | float value;
|
---|
112 | struct
|
---|
113 | {
|
---|
114 | unsigned int fraction0: 7;
|
---|
115 | unsigned int fraction1: 16;
|
---|
116 | unsigned int exponent: 8;
|
---|
117 | unsigned int sign : 1;
|
---|
118 | } number;
|
---|
119 | struct
|
---|
120 | {
|
---|
121 | unsigned int function1:16;
|
---|
122 | unsigned int function0:6;
|
---|
123 | unsigned int quiet:1;
|
---|
124 | unsigned int exponent:8;
|
---|
125 | unsigned int sign:1;
|
---|
126 | } nan;
|
---|
127 | long p1;
|
---|
128 |
|
---|
129 | } __ieee_float_shape_type;
|
---|
130 | #endif
|
---|
131 |
|
---|
132 | #if defined(__IEEE_BIG_ENDIAN) || defined(__IEEE_LITTLE_ENDIAN)
|
---|
133 |
|
---|
134 | double DEFUN(copysign, (x, y), double x AND double y)
|
---|
135 | {
|
---|
136 | __ieee_double_shape_type a,b;
|
---|
137 | b.value = y;
|
---|
138 | a.value = x;
|
---|
139 | a.number.sign =b.number.sign;
|
---|
140 | return a.value;
|
---|
141 | }
|
---|
142 |
|
---|
143 | #else
|
---|
144 |
|
---|
145 | double DEFUN(copysign, (x, y), double x AND double y)
|
---|
146 | {
|
---|
147 | if ((x < 0 && y > 0) || (x > 0 && y < 0))
|
---|
148 | return -x;
|
---|
149 | return x;
|
---|
150 | }
|
---|
151 |
|
---|
152 | #endif
|
---|