Skip to content

Commit 1ac968e

Browse files
committed
fixed quiet comparisons
1 parent 9d6c51f commit 1ac968e

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

quadmath_cpp.h

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <quadmath.h>
1717

1818
#if __cplusplus >= 201103L
19+
/* for fpclassify return values */
1920
#include <cmath>
20-
#include <cfenv>
2121
#endif
2222

2323
/* Classification */
@@ -31,9 +31,11 @@ inline bool issignaling(__float128 x) { return (issignalingq(x) != 0); }
3131
inline bool isunordered(__float128 x, __float128 y) {
3232
return ((isnanq(x) != 0) || (isnanq(y) != 0));
3333
}
34+
3435
inline bool isnormal(__float128 x) {
3536
return ((finiteq(x) != 0) && (fabsq(x) >= FLT128_MIN));
3637
}
38+
3739
inline bool issubnormal(__float128 x) {
3840
return ((finiteq(x) != 0) && (fabsq(x) < FLT128_MIN) && (x != static_cast<__float128>(0.0)));
3941
}
@@ -57,49 +59,40 @@ inline bool islessgreater(__float128 x, __float128 y) {
5759
return ((x != y) && (isnanq(x) == 0) && (isnanq(y) == 0));
5860
}
5961

60-
#if __cplusplus >= 201103L
61-
6262
inline bool isless(__float128 x, __float128 y) {
63-
bool ignore_fe_expection = !std::fetestexcept(FE_INVALID);
64-
bool result = (x < y);
65-
if (ignore_fe_expection) { std::feclearexcept(FE_INVALID); }
66-
return result;
63+
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
64+
return false;
65+
}
66+
return (x < y);
6767
}
68+
6869
inline bool islessequal(__float128 x, __float128 y) {
69-
bool ignore_fe_expection = !std::fetestexcept(FE_INVALID);
70-
bool result = (x <= y);
71-
if (ignore_fe_expection) { std::feclearexcept(FE_INVALID); }
72-
return result;
70+
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
71+
return false;
72+
}
73+
return (x <= y);
7374
}
75+
7476
inline bool isgreater(__float128 x, __float128 y) {
75-
bool ignore_fe_expection = !std::fetestexcept(FE_INVALID);
76-
bool result = (x > y);
77-
if (ignore_fe_expection) { std::feclearexcept(FE_INVALID); }
78-
return result;
77+
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
78+
return false;
79+
}
80+
return (x > y);
7981
}
82+
8083
inline bool isgreaterequal(__float128 x, __float128 y) {
81-
bool ignore_fe_expection = !std::fetestexcept(FE_INVALID);
82-
bool result = (x >= y);
83-
if (ignore_fe_expection) { std::feclearexcept(FE_INVALID); }
84-
return result;
84+
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
85+
return false;
86+
}
87+
return (x >= y);
8588
}
8689

87-
#endif /* __cplusplus >= 201103L */
88-
89-
9090
/* signaling comparison */
9191

92-
#if __cplusplus >= 201103L
93-
9492
inline bool iseqsig(__float128 x, __float128 y) {
95-
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
96-
std::feraiseexcept(FE_INVALID);
97-
}
98-
return (x == y);
93+
return ((x >= y) && (x <= y));
9994
}
10095

101-
#endif /* __cplusplus >= 201103L */
102-
10396
/* Manipulation */
10497

10598
inline __float128 fabs(__float128 x) { return fabsq(x); }
@@ -110,10 +103,10 @@ inline __float128 nexttoward(__float128 x, long double y) { return nextafterq(x,
110103
/* Float Exponents */
111104

112105
inline int ilogb(__float128 x) { return ilogbq(x); }
113-
inline __float128 frexp (__float128 x, int* exp) { return frexpq (x, exp); }
114-
inline __float128 ldexp (__float128 x, int exp) { return ldexpq (x, exp); }
115-
inline __float128 scalbn (__float128 x, int exp) { return scalbnq (x, exp); }
116-
inline __float128 scalbln(__float128 x, long exp) { return scalblnq(x, exp); }
106+
inline __float128 frexp (__float128 x, int* expon) { return frexpq (x, expon); }
107+
inline __float128 ldexp (__float128 x, int expon) { return ldexpq (x, expon); }
108+
inline __float128 scalbn (__float128 x, int expon) { return scalbnq (x, expon); }
109+
inline __float128 scalbln(__float128 x, long expon) { return scalblnq(x, expon); }
117110

118111
/* Arithmetic */
119112

0 commit comments

Comments
 (0)