Monday, May 14, 2012

What is the fastest way to XOR two integers in C#?

I need to XOR one integer a against array of integers q (max of 100,000). i.e. if i am looping, I will a XOR q[0]..... a XOR q[100000] (100,000 times)



I will have a series of such a to be XORed.



I am writing a console application which will be pass the required input.



I am using the built-in C# ^ operator to do the XOR operation. Is there any other way?



Would converting the integer to a byte array and then XORing each bit and figuring out the end result be a good idea?





No comments:

Post a Comment