https://issues.dlang.org/show_bug.cgi?id=24028

          Issue ID: 24028
           Summary: BigInt power operator ignores sign of exponent
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nob...@puremagic.com
          Reporter: snarwin+bugzi...@gmail.com

As of DMD 2.104.0, the assertion in the following program fails:

---
import std.bigint;

void main()
{
    auto n = BigInt(100);
    auto expected = BigInt(1) / BigInt(100);
    assert(n ^^ -1 == expected);
}
---

With -checkaction=context, the error message is:

---
core.exception.AssertError@bug.d(7): BigInt(BigUint([100]), false) !=
BigInt(BigUint([0]), false)
---

Instead of raising n to the power of -1, BigInt's ^^ overload has raised it to
the power of 1.

--

Reply via email to