Signed word lengths and indexes

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jun 17 13:36:28 PDT 2010


Walter Bright wrote:
> Steven Schveighoffer wrote:
>> On Thu, 17 Jun 2010 15:24:52 -0400, Don <nospam at nospam.com> wrote:
>>
>>>
>>> A question I have though is, Java has >>>. Does Java have these 
>>> problems too?
>>
>> Java doesn't have unsigned values, so it's necessary to use regular 
>> int's as bitmasks, hence the extra operator.
> 
> The reason D has >>> is to cause an unsigned right shift to be generated 
> without needing to resort to casts as one has to in C.
> 
> The problem with such casts is they wreck generic code.

No.

http://www.digitalmars.com/d/2.0/phobos/std_traits.html#Unsigned

void fun(T)(T num) if (isIntegral!T)
{
     auto x = cast(Unsigned!T) num;
     ...
}


Andrei


More information about the Digitalmars-d mailing list