www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18224] New: BigInt modulo uint must return long.

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 puremagic.com
          Reporter: markus 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);
}

--
Jan 11