https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125695

            Bug ID: 125695
           Summary: Big_Exp special case for (+/-)2 ** K is broken for -2
                    and even K
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liam at liampwll dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

This comes from
https://www.reddit.com/r/ada/comments/1u17ucp/clueless_about_pow_operator_in_gnat/

To_Big_Integer (-2) ** 2 incorrectly produces a result of 4 due to a missing
parity check. In Big_Exp note the parity check in the third Normalize call
which is missing from the fourth.

To_Big_Integer (-2) ** 1 is also broken since in the code above Normalize is
called without a Neg argument, probably not worth a separate issue since it's a
tiny fix:

         --  X ** 1 is X

         when 1 =>
            return Normalize (X.D);

Both bugs have been present since Big_Integers was added.

Reply via email to