www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10387] New: BigInt lacks opBinary overloads for bitwise operators

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

           Summary: BigInt lacks opBinary overloads for bitwise operators
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: ridimz yahoo.com


--- Comment #0 from ridimz yahoo.com 2013-06-16 21:28:28 PDT ---
Attempting to apply the bitwise operators to BigInt values results
compile time error.

Steps to reproduce:

    void main()
    {
        import std.bigint;
        import std.stdio;

        auto x = BigInt(2), m = BigInt(11);
        auto x1 = x & m;
        auto x2 = x | m;
        auto x3 = x ^ m;
        writeln("x1 = ", x1, " x2 = ", x2, " x3 = ", x3);

        x = BigInt(5), m = BigInt(27);
        x1 = x & m;
        x2 = x | m;
        x3 = x ^ m;
        writeln("x1 = ", x1, " x2 = ", x2, " x3 = ", x3);

        x = BigInt(2), m = BigInt(18);
        x1 = x & m;
        x2 = x | m;
        x3 = x ^ m;
        writeln("x1 = ", x1, " x2 = ", x2, " x3 = ", x3);
    }

Actual results:

    andrew ace:~$ dmd bw
    bw.d(7): Error: 'x' is not of integral type, it is a BigInt
    bw.d(7): Error: 'm' is not of integral type, it is a BigInt
    bw.d(8): Error: 'x' is not of integral type, it is a BigInt
    bw.d(8): Error: 'm' is not of integral type, it is a BigInt
    bw.d(9): Error: 'x' is not of integral type, it is a BigInt
    bw.d(9): Error: 'm' is not of integral type, it is a BigInt
    bw.d(13): Error: 'x' is not of integral type, it is a BigInt
    bw.d(13): Error: 'm' is not of integral type, it is a BigInt
    bw.d(14): Error: 'x' is not of integral type, it is a BigInt
    bw.d(14): Error: 'm' is not of integral type, it is a BigInt
    bw.d(15): Error: 'x' is not of integral type, it is a BigInt
    bw.d(15): Error: 'm' is not of integral type, it is a BigInt
    bw.d(19): Error: 'x' is not of integral type, it is a BigInt
    bw.d(19): Error: 'm' is not of integral type, it is a BigInt
    bw.d(20): Error: 'x' is not of integral type, it is a BigInt
    bw.d(20): Error: 'm' is not of integral type, it is a BigInt
    bw.d(21): Error: 'x' is not of integral type, it is a BigInt
    bw.d(21): Error: 'm' is not of integral type, it is a BigInt

Expected results:

    x1 = 2 x2 = 11 x3 = 9
    x1 = 1 x2 = 31 x3 = 30
    x1 = 2 x2 = 18 x3 = 16

DMD64 D Compiler v2.064-devel-22a06f8 on Mac OS 10.8.4

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