coltsith

Could someone tell me the equivalent of this expression in java:

n >>> 7

but in c# Because c# doesn't support >>>, only >>.

Thanks!


Re: .NET Compact Framework Java logical right bitshift >>> equivalent in c#?

Ilya Tumanov

Cast 'n' to unsigned type then shift with >>, then cast it back, that should do it.






Re: .NET Compact Framework Java logical right bitshift >>> equivalent in c#?

jeff_msft

Just to elaborate a little more, there's some more information about the C# shift operators here:

http://msdn2.microsoft.com/en-US/library/aa691377(VS.71).aspx

In particular, "When the left operand of the >> operator is of an unsigned integral type, the operator performs a logical shift right wherein high-order empty bit positions are always set to zero."

HTH,

--Jeff





Re: .NET Compact Framework Java logical right bitshift >>> equivalent in c#?

coltsith

Okay, thanks guys. N is already an unsigned bit so I guess I'm good to go.




Re: .NET Compact Framework Java logical right bitshift >>> equivalent in c#?

Ilya Tumanov

Yes, you're good to go.

Generally >>> is only needed in Java to compensate for missing unsigned types.

In C# you're better off declaring unsigned type as unsigned instead of using special operations which would treat signed type as unsigned.