aboutsummaryrefslogtreecommitdiff
path: root/flang/runtime/numeric.cpp
diff options
context:
space:
mode:
authorPeter Steinfeld <psteinfeld@nvidia.com>2022-07-07 10:42:47 -0700
committerPeter Steinfeld <psteinfeld@nvidia.com>2022-07-07 12:43:30 -0700
commit9f9e9d9cfc2e2f929c17de4a1065c0eb68e479c0 (patch)
treea87dc6654df600ac60a76926be98d08a71e2ae6d /flang/runtime/numeric.cpp
parentb9e642afd152c2819d91bfaea028a81ff4e9454e (diff)
downloadllvm-9f9e9d9cfc2e2f929c17de4a1065c0eb68e479c0.zip
llvm-9f9e9d9cfc2e2f929c17de4a1065c0eb68e479c0.tar.gz
llvm-9f9e9d9cfc2e2f929c17de4a1065c0eb68e479c0.tar.bz2
[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
Diffstat (limited to 'flang/runtime/numeric.cpp')
-rw-r--r--flang/runtime/numeric.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp
index 8d02973..a989d3a 100644
--- a/flang/runtime/numeric.cpp
+++ b/flang/runtime/numeric.cpp
@@ -122,7 +122,7 @@ template <typename T> inline T SetExponent(T x, std::int64_t p) {
} else if (std::isinf(x)) {
return std::numeric_limits<T>::quiet_NaN(); // +/-Inf -> NaN
} else if (x == 0) {
- return 0; // 0 -> 0
+ return x; // return negative zero if x is negative zero
} else {
int expo{std::ilogb(x) + 1};
auto ip{static_cast<int>(p - expo)};