digitalmars.D.bugs - [Issue 24028] New: BigInt power operator ignores sign of exponent
- d-bugmail puremagic.com (31/31) Jul 03 2023 https://issues.dlang.org/show_bug.cgi?id=24028
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: nobody puremagic.com Reporter: snarwin+bugzilla 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. --
Jul 03 2023