[Issue 7079] New: BigInt bool assign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 8 04:13:18 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=7079

           Summary: BigInt bool assign
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-12-08 04:13:14 PST ---
For uniformity with normal integers I'd like this D2 program to work:


import std.bigint;
void main() {
    BigInt b = true;
}


But with dmd 2.057beta it gives:

...\dmd2\src\phobos\std\bigint.d(117): Error: operation not allowed on bool 'x'


I think an opAssign similar to this one solves the problem:


    void opAssign(T: long)(T x)
    {
        static if (is(T == bool))
        {
            data = cast(ulong)x;
            sign = false;
        }
        else
        {
            data = cast(ulong)((x < 0) ? -x : x);
            sign = (x < 0);
        }
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list