From 242407d85307642c282d64ad80ba30075e8443aa Mon Sep 17 00:00:00 2001 From: peter klausler Date: Tue, 29 Jan 2019 16:15:35 -0800 Subject: [PATCH] [flang] Fix bugs flang-compiler/f18#269 & flang-compiler/f18#270 Original-commit: flang-compiler/f18@639816f3efa7907d07c724e15d13afa5d4fe7794 Reviewed-on: https://github.com/flang-compiler/f18/pull/272 Tree-same-pre-rewrite: false --- flang/lib/evaluate/real.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flang/lib/evaluate/real.h b/flang/lib/evaluate/real.h index 395eaed..27a8b3f 100644 --- a/flang/lib/evaluate/real.h +++ b/flang/lib/evaluate/real.h @@ -279,9 +279,15 @@ public: ValueWithRealFlags result; int exponent{exponentBias + x.Exponent() - A::exponentBias}; int bitsLost{A::precision - precision}; + if (exponent < 0) { + // Make result Denormal + bitsLost += -exponent; + exponent = 0; + } typename A::Fraction xFraction{x.GetFraction()}; if (bitsLost <= 0) { - Fraction fraction{Fraction::ConvertUnsigned(xFraction).value}; + Fraction fraction{ + Fraction::ConvertUnsigned(xFraction).value.SHIFTL(-bitsLost)}; result.flags |= result.value.Normalize(isNegative, exponent, fraction); } else { Fraction fraction{ -- 2.7.4