Bitwise NOT

A

Aamir Mahmood

hi
how can i perform a bitwise NOT on a int or long or uint type variable?
so that the bits should be inverted in the result.

-
aamir
 
J

Jon Skeet [C# MVP]

Aamir Mahmood said:
how can i perform a bitwise NOT on a int or long or uint type variable?
so that the bits should be inverted in the result.

~ is the bitwise not operator. For instance:

uint x = 0x1234;
uint y = ~x;

y is now 0xffffedcb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top