diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp index 8d0297317b4df..a989d3a43a4d0 100644 --- a/flang/runtime/numeric.cpp +++ b/flang/runtime/numeric.cpp @@ -122,7 +122,7 @@ template inline T SetExponent(T x, std::int64_t p) { } else if (std::isinf(x)) { return std::numeric_limits::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(p - expo)};