This source file includes following definitions.
- sgl_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 #include "float.h"
30 #include "sgl_float.h"
31
32
33
34
35 int
36 sgl_fcmp (sgl_floating_point * leftptr, sgl_floating_point * rightptr,
37 unsigned int cond, unsigned int *status)
38
39
40
41 {
42 register unsigned int left, right;
43 register int xorresult;
44
45
46 left = *leftptr;
47 right = *rightptr;
48
49
50
51
52 if( (Sgl_exponent(left) == SGL_INFINITY_EXPONENT)
53 || (Sgl_exponent(right) == SGL_INFINITY_EXPONENT) )
54 {
55
56
57
58 if( ( (Sgl_exponent(left) == SGL_INFINITY_EXPONENT)
59 && Sgl_isnotzero_mantissa(left)
60 && (Exception(cond) || Sgl_isone_signaling(left)))
61 ||
62 ( (Sgl_exponent(right) == SGL_INFINITY_EXPONENT)
63 && Sgl_isnotzero_mantissa(right)
64 && (Exception(cond) || Sgl_isone_signaling(right)) ) )
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( ((Sgl_exponent(left) == SGL_INFINITY_EXPONENT)
77 && Sgl_isnotzero_mantissa(left))
78 ||
79 ((Sgl_exponent(right) == SGL_INFINITY_EXPONENT)
80 && Sgl_isnotzero_mantissa(right)) )
81 {
82
83 Set_status_cbit(Unordered(cond));
84 return(NOEXCEPTION);
85 }
86
87 }
88
89
90 Sgl_xortointp1(left,right,xorresult);
91 if( xorresult < 0 )
92 {
93
94
95 if( Sgl_iszero_exponentmantissa(left)
96 && Sgl_iszero_exponentmantissa(right) )
97 {
98 Set_status_cbit(Equal(cond));
99 }
100 else if( Sgl_isone_sign(left) )
101 {
102 Set_status_cbit(Lessthan(cond));
103 }
104 else
105 {
106 Set_status_cbit(Greaterthan(cond));
107 }
108 }
109
110
111 else if( Sgl_all(left) == Sgl_all(right) )
112 {
113 Set_status_cbit(Equal(cond));
114 }
115 else if( Sgl_iszero_sign(left) )
116 {
117
118 if( Sgl_all(left) < Sgl_all(right) )
119 {
120 Set_status_cbit(Lessthan(cond));
121 }
122 else
123 {
124 Set_status_cbit(Greaterthan(cond));
125 }
126 }
127 else
128 {
129
130
131
132 if( Sgl_all(left) > Sgl_all(right) )
133 {
134 Set_status_cbit(Lessthan(cond));
135 }
136 else
137 {
138 Set_status_cbit(Greaterthan(cond));
139 }
140 }
141 return(NOEXCEPTION);
142 }