diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/ada/eval_fat.adb | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/ada/eval_fat.adb')
-rw-r--r-- | gcc/ada/eval_fat.adb | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/gcc/ada/eval_fat.adb b/gcc/ada/eval_fat.adb index 8160cba..68a25d1 100644 --- a/gcc/ada/eval_fat.adb +++ b/gcc/ada/eval_fat.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2021, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -23,10 +23,11 @@ -- -- ------------------------------------------------------------------------------ -with Einfo; use Einfo; -with Errout; use Errout; -with Opt; use Opt; -with Sem_Util; use Sem_Util; +with Einfo; use Einfo; +with Einfo.Utils; use Einfo.Utils; +with Errout; use Errout; +with Opt; use Opt; +with Sem_Util; use Sem_Util; package body Eval_Fat is @@ -729,30 +730,40 @@ package body Eval_Fat is New_Frac : T; begin + -- Treat zero as a regular denormalized number if they are supported, + -- otherwise return the smallest normalized number. + if UR_Is_Zero (X) then - Exp := Emin; + if Has_Denormals (RT) then + Exp := Emin; + else + return Scaling (RT, Ureal_Half, Emin); + end if; end if; - -- Set exponent such that the radix point will be directly following the - -- mantissa after scaling. - - if Has_Denormals (RT) or Exp /= Emin then - Exp := Exp - Mantissa; - else - Exp := Exp - 1; - end if; + -- Multiply the number by 2.0**(Mantissa-Exp) so that the radix point + -- will be directly following the mantissa after scaling. + Exp := Exp - Mantissa; Frac := Scaling (RT, X, -Exp); + + -- Round to the neareast integer towards +Inf + New_Frac := Ceiling (RT, Frac); + -- If the rounding was a NOP, add one, except for -2.0**(Mantissa-1) + -- because the exponent is going to be reduced. + if New_Frac = Frac then if New_Frac = Scaling (RT, -Ureal_1, Mantissa - 1) then - New_Frac := New_Frac + Scaling (RT, Ureal_1, Uint_Minus_1); + New_Frac := New_Frac + Ureal_Half; else New_Frac := New_Frac + Ureal_1; end if; end if; + -- Divide back by 2.0**(Mantissa-Exp) to get the final result + return Scaling (RT, New_Frac, Exp); end Succ; |