Class BitUtil
Utility for bit control for integer.
public static class BitUtil
- Inheritance
-
BitUtil
- Inherited Members
Methods
GetBit(int, int)
Get bit from the given position of the target integer.
public static bool GetBit(this int src, int pos)
Parameters
Returns
- bool
the bit at the given position
GetSetBit(int, int, bool)
Sets a bit at the specified position and returns the modified value without changing the original.
public static int GetSetBit(this int src, int pos, bool v)
Parameters
src
intSource integer value
pos
intBit position to set
v
boolValue to set (true for 1, false for 0)
Returns
- int
The modified integer with the bit set at the specified position
SetBit(ref int, int, bool)
set bit value at given position of an integer
public static int SetBit(this ref int src, int pos, bool v)
Parameters
Returns
- int
the target integer
SwitchBit(BitArray, int)
Switches (toggles) the bit at the specified position in a BitArray.
public static BitArray SwitchBit(this BitArray hdl, int pos)
Parameters
Returns
- BitArray
The modified BitArray