diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp --- a/flang/runtime/numeric.cpp +++ b/flang/runtime/numeric.cpp @@ -122,7 +122,7 @@ } 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)};