BitMath Class

Contains some random and useful functions.

Definition

Namespace: Gemstone
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
public static class BitMath
Inheritance
Object    BitMath

Methods

CountBitsCleared(UInt32) Counts the number of bits that are not set
CountBitsCleared(UInt64) Counts the number of bits that are not set
CountBitsSet(UInt32) Counts the number of bits that are set
CountBitsSet(UInt64) Counts the number of bits that are set
CountLeadingOnes(UInt32) Counts the number of consecutive 1's starting from the highest bit working down.
CountLeadingOnes(UInt64) Counts the number of consecutive 1's starting from the highest bit working down.
CountLeadingZeros(UInt32) Counts the number of consecutive 0's starting from the highest bit working down.
CountLeadingZeros(UInt64) Counts the number of consecutive 0's starting from the highest bit working down.
CountTrailingOnes(UInt32) Counts the number of consecutive 1's starting from the lowest bit working up.
CountTrailingOnes(UInt64) Counts the number of consecutive 1's starting from the lowest bit working up.
CountTrailingZeros(UInt32) Counts the number of consecutive 0's starting from the lowest bit working up.
CountTrailingZeros(UInt64) Counts the number of consecutive 0's starting from the lowest bit working up.
CreateBitMask Creates a bit mask for a number with the given number of bits.
GetClearedBitPositions(UInt32) Returns the bit position for every bit that is cleared in the provided value. Bit positions are defined as 0-31;
GetClearedBitPositions(UInt64) Returns the bit position for every bit that is cleared in the provided value. Bit positions are defined as 0-63;
GetSetBitPositions(UInt32) Returns the bit position for every bit that is set in the provided value. Bit positions are defined as 0-31;
GetSetBitPositions(UInt64) Returns the bit position for every bit that is set in the provided value. Bit positions are defined as 0-63;
IsPowerOfTwo(Int32) Determines if the number is a power of 2.
IsPowerOfTwo(Int64) Determines if the number is a power of 2.
IsPowerOfTwo(UInt32) Determines if the number is a power of 2.
IsPowerOfTwo(UInt64) Determines if the number is a power of 2.
RoundDownToNearestPowerOfTwo(UInt32) Rounds a number down to the nearest power of 2. If the value is a power of two, the same value is returned. If value is zero, 1 is returned.
RoundDownToNearestPowerOfTwo(UInt64) Rounds a number down to the nearest power of 2. If the value is a power of two, the same value is returned. If value is zero, one is returned.
RoundUpToNearestPowerOfTwo(UInt32) Rounds a number up to the nearest power of 2. If the value is a power of two, the same value is returned. If the value is larger than the largest power of 2. It is rounded down.
RoundUpToNearestPowerOfTwo(UInt64) Rounds a number up to the nearest power of 2. If the value is a power of two, the same value is returned. If the value is larger than the largest power of 2. It is rounded down.

See Also