Bug 24028 – BigInt power operator ignores sign of exponent
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-07-03T14:09:10Z
Last change time
2023-07-03T17:26:58Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2023-07-03T14:09:10Z
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:
---
[email protected](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.
Comment #1 by dlang-bot — 2023-07-03T14:55:41Z
@pbackus created dlang/phobos pull request #8779 "Fix issue 24028 - BigInt power operator ignores sign of exponent" fixing this issue:
- Fix issue 24028 - BigInt power operator ignores sign of exponent
https://github.com/dlang/phobos/pull/8779
Comment #2 by dlang-bot — 2023-07-03T17:26:58Z
dlang/phobos pull request #8779 "Fix issue 24028 - BigInt power operator ignores sign of exponent" was merged into master:
- afe5d47167a93798444d24a4ac88a90007736538 by Paul Backus:
Fix issue 24028 - BigInt power operator ignores sign of exponent
https://github.com/dlang/phobos/pull/8779