I think that it is very good article, too! In the good old days the bitwise operators were part of our everyday life. Now they are used only from the good devs which still think for performance.

P.S. Why not adding some words about << and >> just to cover the whole topic?

If we want to get 0 for 101 and 1 for 100,it can be assumed that only the LSB is used for XOR operation,now if we XOR the number with 1,i.e.001 then we get the desired output.

Cool use of the ~ operator is the binary search method in the List class. It returns a negative integer when it can't find the specified item. This negative integer becomes the correct insertion point to keep the list sorted, when you apply the ~ operator.

I have to compute for binary Not AND(NAND), NOR and XNOR(Exclusive NOR)in C#. operator ~ and ! are not support for NAND, NOR and XNOR. so pls tell me how to ..

Very impressive. Short, but to the point. I skipped class yesterday an apparently they spent the whole hour going over c# bitwise operators. Took ten min of reading this article to catch up lol.

## Comments

## Seshasai said:

Its excellent. Great job.

## Vesko Kolev said:

I think that it is very good article, too! In the good old days the bitwise operators were part of our everyday life. Now they are used only from the good devs which still think for performance.

P.S. Why not adding some words about << and >> just to cover the whole topic?

Thanks again!

## Brad said:

it is not helpful as I am finding the operator for XNOR operation.

I encrypt the password using XOR operator, now i want to decrypt it. What is the process to achieve this?

## Brad2 said:

Brad, if you XOR something, just XOR it again to get back your original value.

## chethan said:

i want the logic as how to write bitwise xor like

for 101 we get 0 by doing bitwise xor

for 100 we get 1 by doing bitwise xor

## ARUNIMA BHATTACHARYA said:

A GOOD STUFF INDEED.I want to add: If one XORs anything twice he will get the actual number again.That is how one can use it to encrypt and decrypt.

## Arunima Bhattacharya said:

If we want to get 0 for 101 and 1 for 100,it can be assumed that only the LSB is used for XOR operation,now if we XOR the number with 1,i.e.001 then we get the desired output.

## fako said:

this article really helps

## Vojtěch Vít said:

My Thanks to the author. This article is short but very, very clear:-)

## laila said:

greet job:)

but these are built in functions

## F2F said:

i don't understand this article.

for example:

var a = 1;

var b = 2;

if (a == b ) {

//do sothing.

}

if i use bitwise operators, i will write:

if (a & b == a) {

//do sothing

}

is it true ? how about other operators ?

Please help me.

## Alex van Beek said:

Cool use of the ~ operator is the binary search method in the List class. It returns a negative integer when it can't find the specified item. This negative integer becomes the correct insertion point to keep the list sorted, when you apply the ~ operator.

## Kyi Thar said:

Pls help me..

I have to compute for binary Not AND(NAND), NOR and XNOR(Exclusive NOR)in C#. operator ~ and ! are not support for NAND, NOR and XNOR. so pls tell me how to ..

NAND (Not AND)

0 NAN 0 = 1

0 NAN 1 = 1

1 NAN 0 = 1

1 NAN 1 = 0

NOR (Not OR)

0 NOR 0 = 1

0 NOR 1 = 0

1 NOR 0 = 0

1 NOR 1 = 0

XNOR (Exclusive NOR)

0 XOR 0 = 1

0 XOR 1 = 0

1 XOR 0 = 0

1 XOR 1 = 1

## Chris said:

Thanks, very well written and easy to understand post.

## Ganesh said:

Waw gr8 examples,

It's really helpfull for me.

Thankx

## Jaroslaw Dobrzanski said:

Exactly what I was looking for. Thanks!

## arshpreet said:

thanks..........

u hav done a great job....

i was trying to get it form months.........

thanks a lot>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

## Brice said:

Very impressive. Short, but to the point. I skipped class yesterday an apparently they spent the whole hour going over c# bitwise operators. Took ten min of reading this article to catch up lol.

## Deepak said:

Thanks for writing such an understanding article on Bitwize

## Jake said:

really helpful, thx. some tricks with ~, good explained. As <keep complex...> asked: what's one's complement?