For a byte, probably the quickest way is to create an array of 256 boolean that indicate for a given byte value whether it is even or odd parity. You only have to initialize the array when the containing class is loaded. At this point speed does not matter.
To fill the array you can use
static int parity(byte value)
{
int v = (value >> 4) ^ value;
v = (v >> 2) ^ v;
v = (v >> 1) ^ v;
return v & 0x1;
}
Sorry Sir. I was in work tension that was the main reason, but the idea which you gave is very great. I was trying to use that in my program. In future I won't repeat.
> I really don't understand why people post questions
> and then ignore answers. From his other posts I know
> the OP has visited these forums since I posted this
> so why has he not acknowledge my response. I can only
> think that his is an ignorant twit.
>
> One more to ignore in the future.