Re: >>> ??

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 06/10/04


Date: Thu, 10 Jun 2004 15:49:35 -0400


"Brad White" <bwhite at inebraska . com> wrote in message
news:Osj0kDyTEHA.2844@TK2MSFTNGP12.phx.gbl
> I've never seen >>> before, and google doesn't handle symbols.
>
> What is going on here?
>
>
> int inthash(int key)
> { key += ~(key << 15);
> key ^= (key >>> 10);
> key += (key << 3);
> key ^= (key >>> 6);
> key += ~(key << 11);
> key ^= (key >>> 16);
> return key;}

Is it Java or C# code, by any chance? I seem to remember that in these
two, >>> means zero-extended right shift, whereas >> is sign-extended
right shift. With the former, vacant bits to the left are filled with
zeros. With the latter, vacant bits to the left are filled with a copy
of the original leftmost bit, thus preserving the sign of the value on
two's complement machines.

-- 
With best wishes,
    Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Relevant Pages

  • Re: function to count number of set bits
    ... > function properly as a set-bit counter on non 2s complement machines ... rightmost set bit on all implementations - negative 'even' integers in ... > | int bitcount ...
    (comp.lang.c)
  • Re: checking array indices
    ... there is no negative value of type int that yields a value less ... >> representations where this isn't the case.) ... > zero machine cycles on two's complement machines. ... In an assert, this is ...
    (comp.lang.c)
  • Re: Reading little-endian data from a file in a portable manner
    ... it is 32768 and that does not fit in a 16-bit int either. ... the standard was tweaked to work on two's complement machines. ... So all the extremes are OK. ...
    (comp.lang.c)
  • Re: function to count number of set bits
    ... > function properly as a set-bit counter on non 2s complement machines ... > | int bitcount ... implementations, `b' will be initialized to INT_MIN, -2147483648 -- ... representation of -1 on a signed magnitude machine has two ...
    (comp.lang.c)
  • Re: Microsoft Visual Studio
    ... Sig line vacant - apply within ... int func ... int ans = func; ...
    (comp.lang.c)