Unnamed
public text v1 · immutable // Get Bit from a byte specified.
// Pass 0-7 for the bitNum param, where 0 is the least significant bit.
public static byte GetBit(byte uByte, int bitNum)
{
// ^ is not to the power in C#! It's XOR. Use System.Math.Pow()
// Return desired bit. --
if ((uByte & (byte)Math.Pow(2, bitNum)) > 0)
{
return 1;
} else {
return 0;
}
}