Bug 18224 – BigInt modulo uint must return long.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-01-11T08:10:37Z
Last change time
2018-01-14T12:41:17Z
Assigned to
No Owner
Creator
mfx

Comments

Comment #0 by markus — 2018-01-11T08:10:37Z
The valid result from BigInt % uint ranges from -4_294_967_294 to 4_294_967_294, so it must return a long and not an int. import std.bigint; void main() { // current 2.078.0 result - WRONG assert(BigInt( 4_294_967_294) % 4_294_967_295U == -2); assert(BigInt(-4_294_967_294) % 4_294_967_295U == 2); // expected result - currently fails assert(BigInt( 4_294_967_294) % 4_294_967_295U == 4_294_967_294); assert(BigInt(-4_294_967_294) % 4_294_967_295U == -4_294_967_294); }
Comment #1 by markus — 2018-01-11T08:14:12Z
Created github pull request https://github.com/dlang/phobos/pull/6025
Comment #2 by github-bugzilla — 2018-01-13T15:24:37Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/1115ccb219db8aa7f2288f75beead08068522d4d Fix issue 18224 - BigInt modulo uint must return long. https://github.com/dlang/phobos/commit/937b38cf9af0ddd31c4af63c16b1d1fa269aa0b0 Merge pull request #6025 from markus-oberhumer/fix-bigint-mod-uint Fix issue 18224 - BigInt modulo uint must return long. merged-on-behalf-of: Jack Stouffer <[email protected]>
Comment #3 by b2.temp — 2018-01-14T12:41:17Z
*** Issue 15211 has been marked as a duplicate of this issue. ***