Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unsigned Bit Shifting

Status
Not open for further replies.

Rewbs

Programmer
May 1, 2002
18
GB
Hi all,

I need to perform unsigned bit shifting on integers in a C# program. In Java you can do this with the >>> operator. There's no such operator in C#. Any ideas on how I could implement it?

Cheers,
Robin.
 
Got it!
The solution is of course:

x >>> y; becomes (uint) x >> y;

If your x is a constant negative integer, you'll need to do:
unchecked{ (uint) x >> y; }

Best Regards,
Robin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top