www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12974] New: Integer constant exponentiation gives wrong value

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

          Issue ID: 12974
           Summary: Integer constant exponentiation gives wrong value
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: safety0ff.bugz gmail.com

Applying the unit tests from my own integer power function:

import std.math;
void main()
{
    ulong uimax = uint.max;
    assert(uimax^^2uL == 18446744065119617025uL); //passes
    ulong three = 3uL;
    assert(three^^40uL == 12157665459056928801uL); // passes

    assert((cast(ulong)uint.max)^^40uL == 12157665459056928801uL); // error
    assert((3uL)^^40uL == 12157665459056928801uL); // error
}

--
Jun 23 2014