[flang] SET_EXPONENT(-0.0) should return -0.0

Section 16.9.171 says:

If X has the value zero, the result has the same value as X

So if X is -0.0, SET_EXPONENT should return -0.0.

Differential Revision: https://reviews.llvm.org/D129309
This commit is contained in:
Peter Steinfeld 2022-07-07 10:42:47 -07:00
parent b9e642afd1
commit 9f9e9d9cfc
1 changed files with 1 additions and 1 deletions

View File

@ -122,7 +122,7 @@ template <typename T> inline T SetExponent(T x, std::int64_t p) {
} else if (std::isinf(x)) { } else if (std::isinf(x)) {
return std::numeric_limits<T>::quiet_NaN(); // +/-Inf -> NaN return std::numeric_limits<T>::quiet_NaN(); // +/-Inf -> NaN
} else if (x == 0) { } else if (x == 0) {
return 0; // 0 -> 0 return x; // return negative zero if x is negative zero
} else { } else {
int expo{std::ilogb(x) + 1}; int expo{std::ilogb(x) + 1};
auto ip{static_cast<int>(p - expo)}; auto ip{static_cast<int>(p - expo)};