diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp --- a/flang/lib/Evaluate/real.cpp +++ b/flang/lib/Evaluate/real.cpp @@ -749,8 +749,7 @@ return TINY(); } else { Real result; - result.Normalize( - false, Exponent() - binaryPrecision + 1, Fraction::MASKL(1)); + result.Normalize(false, Exponent(), Fraction::MASKR(1)); return result; } } diff --git a/flang/test/Evaluate/fold-spacing.f90 b/flang/test/Evaluate/fold-spacing.f90 --- a/flang/test/Evaluate/fold-spacing.f90 +++ b/flang/test/Evaluate/fold-spacing.f90 @@ -5,6 +5,8 @@ logical, parameter :: test_2 = spacing(-3.0) == scale(1.0, -22) logical, parameter :: test_3 = spacing(3.0d0) == scale(1.0, -51) logical, parameter :: test_4 = spacing(0.) == tiny(0.) + logical, parameter :: test_5 = spacing(tiny(0.)) == 1.e-45 + logical, parameter :: test_6 = spacing(8388608.) == 1. logical, parameter :: test_11 = rrspacing(3.0) == scale(0.75, 24) logical, parameter :: test_12 = rrspacing(-3.0) == scale(0.75, 24) logical, parameter :: test_13 = rrspacing(3.0d0) == scale(0.75, 53)