yank '>>>'?

dsimcha dsimcha at yahoo.com
Sun Dec 6 09:30:14 PST 2009


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> D has operator >>> which means "unsigned shift to the right", inherited
> from Java. But it doesn't need it because D has unsigned types, which
> can be used to effect unsigned shift. (Java, lacking unsigned types, had
> no other way around but to define a new operator.)
> Should we yank operator>>>?
> Andrei

I've never used >>> before, so I'm not 100% sure I understand what it's supposed
to do.  However, I wrote a test program to see if it does what I think, and if my
understanding is correct, it's not even properly implemented.  The fact that
noone's noticed until now is a pretty clear indication that noone uses >>> .

Test program:

import std.stdio;

void main() {
    int i = 0b10000000_00000000_00000000_00000010;

    int iSigned = i >> 2;
    writefln(" int  >>:  %.32b", iSigned);

    int iUnsigned = i >>> 2;
    writefln(" int >>>:  %.32b", iUnsigned);

    uint u = cast(uint) i;

    uint uSigned = u >> 2;
    writefln(" uint >>:  %.32b", uSigned);

    uint uUnsigned = u >>> 2;
    writefln("uint >>>:  %.32b", uUnsigned);
}

Output (DMD 2.037):

 int  >>:  11100000000000000000000000000000
 int >>>:  11100000000000000000000000000000
 uint >>:  00100000000000000000000000000000
uint >>>:  00100000000000000000000000000000



More information about the Digitalmars-d mailing list