Table of Contents

Class BitUtil

Namespace
Hi.Common
Assembly
HiGeom.dll

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

src int

target integer

pos int

the bit position

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 int

Source integer value

pos int

Bit position to set

v bool

Value 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

src int

target integer

pos int

the bit position

v bool

given value

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

hdl BitArray

The BitArray to modify

pos int

The position of the bit to toggle

Returns

BitArray

The modified BitArray