C# Class System.Xml.Bits

Contains static utility methods used to manipulate bits in a word.
显示文件 Open project: gbarnett/shared-source-cli-2.0 Class Usage Examples

Public Methods

Method Description
ClearLeast ( uint num ) : uint

Clear the least significant bit that is set and return the result.

Count ( uint num ) : int

Returns the number of 1 bits in an unsigned integer. Counts bits by divide-and-conquer method, first computing 16 2-bit counts, then 8 4-bit counts, then 4 8-bit counts, then 2 16-bit counts, and finally 1 32-bit count.

ExactlyOne ( uint num ) : bool

Returns true if the unsigned integer has exactly one bit set.

LeastPosition ( uint num ) : int

Compute the 1-based position of the least sigificant bit that is set, and return it (return 0 if no bits are set). (e.g. 0x1001100 will return 3, since the 3rd bit is set).

MoreThanOne ( uint num ) : bool

Returns true if the unsigned integer has more than one bit set.

Method Details

ClearLeast() public static method

Clear the least significant bit that is set and return the result.
public static ClearLeast ( uint num ) : uint
num uint
return uint

Count() public static method

Returns the number of 1 bits in an unsigned integer. Counts bits by divide-and-conquer method, first computing 16 2-bit counts, then 8 4-bit counts, then 4 8-bit counts, then 2 16-bit counts, and finally 1 32-bit count.
public static Count ( uint num ) : int
num uint
return int

ExactlyOne() public static method

Returns true if the unsigned integer has exactly one bit set.
public static ExactlyOne ( uint num ) : bool
num uint
return bool

LeastPosition() public static method

Compute the 1-based position of the least sigificant bit that is set, and return it (return 0 if no bits are set). (e.g. 0x1001100 will return 3, since the 3rd bit is set).
public static LeastPosition ( uint num ) : int
num uint
return int

MoreThanOne() public static method

Returns true if the unsigned integer has more than one bit set.
public static MoreThanOne ( uint num ) : bool
num uint
return bool