[Issue 18224] New: BigInt modulo uint must return long.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 11 08:10:37 UTC 2018


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

          Issue ID: 18224
           Summary: BigInt modulo uint must return long.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: markus at oberhumer.com

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);
}

--


More information about the Digitalmars-d-bugs mailing list