This source file includes following definitions.
- dbl_fcmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include "float.h"
31 #include "dbl_float.h"
32
33
34
35
36 int
37 dbl_fcmp (dbl_floating_point * leftptr, dbl_floating_point * rightptr,
38 unsigned int cond, unsigned int *status)
39
40
41
42 {
43 register unsigned int leftp1, leftp2, rightp1, rightp2;
44 register int xorresult;
45
46
47 Dbl_copyfromptr(leftptr,leftp1,leftp2);
48 Dbl_copyfromptr(rightptr,rightp1,rightp2);
49
50
51
52 if( (Dbl_exponent(leftp1) == DBL_INFINITY_EXPONENT)
53 || (Dbl_exponent(rightp1) == DBL_INFINITY_EXPONENT) )
54 {
55
56
57
58 if( ((Dbl_exponent(leftp1) == DBL_INFINITY_EXPONENT)
59 && Dbl_isnotzero_mantissa(leftp1,leftp2)
60 && (Exception(cond) || Dbl_isone_signaling(leftp1)))
61 ||
62 ((Dbl_exponent(rightp1) == DBL_INFINITY_EXPONENT)
63 && Dbl_isnotzero_mantissa(rightp1,rightp2)
64 && (Exception(cond) || Dbl_isone_signaling(rightp1))) )
65 {
66 if( Is_invalidtrap_enabled() ) {
67 Set_status_cbit(Unordered(cond));
68 return(INVALIDEXCEPTION);
69 }
70 else Set_invalidflag();
71 Set_status_cbit(Unordered(cond));
72 return(NOEXCEPTION);
73 }
74
75
76 else if( ((Dbl_exponent(leftp1) == DBL_INFINITY_EXPONENT)
77 && Dbl_isnotzero_mantissa(leftp1,leftp2))
78 ||
79 ((Dbl_exponent(rightp1) == DBL_INFINITY_EXPONENT)
80 && Dbl_isnotzero_mantissa(rightp1,rightp2)) )
81 {
82
83 Set_status_cbit(Unordered(cond));
84 return(NOEXCEPTION);
85 }
86
87 }
88
89
90 Dbl_xortointp1(leftp1,rightp1,xorresult);
91 if( xorresult < 0 )
92 {
93
94
95 if( Dbl_iszero_exponentmantissa(leftp1,leftp2)
96 && Dbl_iszero_exponentmantissa(rightp1,rightp2) )
97 {
98 Set_status_cbit(Equal(cond));
99 }
100 else if( Dbl_isone_sign(leftp1) )
101 {
102 Set_status_cbit(Lessthan(cond));
103 }
104 else
105 {
106 Set_status_cbit(Greaterthan(cond));
107 }
108 }
109
110
111 else if(Dbl_isequal(leftp1,leftp2,rightp1,rightp2))
112 {
113 Set_status_cbit(Equal(cond));
114 }
115 else if( Dbl_iszero_sign(leftp1) )
116 {
117
118 if( Dbl_allp1(leftp1) < Dbl_allp1(rightp1) )
119 {
120 Set_status_cbit(Lessthan(cond));
121 }
122 else if( Dbl_allp1(leftp1) > Dbl_allp1(rightp1) )
123 {
124 Set_status_cbit(Greaterthan(cond));
125 }
126 else
127 {
128
129
130 if( Dbl_allp2(leftp2) < Dbl_allp2(rightp2) )
131 {
132 Set_status_cbit(Lessthan(cond));
133 }
134 else
135 {
136 Set_status_cbit(Greaterthan(cond));
137 }
138 }
139 }
140 else
141 {
142
143
144
145 if( Dbl_allp1(leftp1) > Dbl_allp1(rightp1) )
146 {
147 Set_status_cbit(Lessthan(cond));
148 }
149 else if( Dbl_allp1(leftp1) < Dbl_allp1(rightp1) )
150 {
151 Set_status_cbit(Greaterthan(cond));
152 }
153 else
154 {
155
156
157 if( Dbl_allp2(leftp2) > Dbl_allp2(rightp2) )
158 {
159 Set_status_cbit(Lessthan(cond));
160 }
161 else
162 {
163 Set_status_cbit(Greaterthan(cond));
164 }
165 }
166 }
167 return(NOEXCEPTION);
168 }