projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b9e642a
)
[flang] SET_EXPONENT(-0.0) should return -0.0
author
Peter Steinfeld
<psteinfeld@nvidia.com>
Thu, 7 Jul 2022 17:42:47 +0000
(10:42 -0700)
committer
Peter Steinfeld
<psteinfeld@nvidia.com>
Thu, 7 Jul 2022 19:43:30 +0000
(12:43 -0700)
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
flang/runtime/numeric.cpp
patch
|
blob
|
history
diff --git
a/flang/runtime/numeric.cpp
b/flang/runtime/numeric.cpp
index
8d02973
..
a989d3a
100644
(file)
--- 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)};