[Ada] Error in Big_Real comparison
authorArnaud Charlet <charlet@adacore.com>
Fri, 30 Oct 2020 15:17:29 +0000 (11:17 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 27 Nov 2020 09:15:40 +0000 (04:15 -0500)
gcc/ada/

* libgnat/a-nbnbre.adb ("=", "<"): Fix.

gcc/ada/libgnat/a-nbnbre.adb

index ff5b448..e5d810e 100644 (file)
@@ -29,8 +29,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  This is the default version of this package, based on Big_Integers only.
-
 with Ada.Strings.Text_Output.Utils;
 with System.Img_Real; use System.Img_Real;
 
@@ -85,14 +83,16 @@ package body Ada.Numerics.Big_Numbers.Big_Reals is
    ---------
 
    function "=" (L, R : Valid_Big_Real) return Boolean is
-     (abs L.Num = abs R.Num and then L.Den = R.Den);
+     (L.Num = R.Num and then L.Den = R.Den);
 
    ---------
    -- "<" --
    ---------
 
    function "<" (L, R : Valid_Big_Real) return Boolean is
-     (abs L.Num * R.Den < abs R.Num * L.Den);
+     (L.Num * R.Den < R.Num * L.Den);
+   --  The denominator is guaranteed to be positive since Normalized is
+   --  always called when constructing a Valid_Big_Real
 
    ----------
    -- "<=" --