A bit manipulation readability enhancement library.
Provides bit counting and other niche bit manipulation facilities for System.Byte values.
public static class ByteAlgorithmsExtensions
Inheritance System.Object đŸ¡’ ByteAlgorithmsExtensions
Methods | Â |
---|---|
AreOnlyFirstAndLastBitsSet(this byte) | Determines if only the lowest bit and one other higher bit are set. |
CountBitsSet(this byte) | Counts the bits that are set to 1 in a number. |
CountLeadingZeros(this byte) | Computes the number of sequentially zeroed bits occupying the most significant bit positions. |
CountTrailingZeros(this byte) | Computes the number of sequentially zeroed bits occupying the least significant bit positions. |
GetHighestBitSet(this byte) | Calculate the index of the highest bit that’s been set. |
GetLowestBitSet(this byte) | Calculate the index of the lowest bit that’s been set. |
GetSign(this byte) | Returns a value indicating the sign of the number. |
IsEven(this byte) | Determines if the number is odd. |
IsNegative(this byte) | Indicates if the number is negative. (Always false for unsigned numbers) |
IsOdd(this byte) | Determines if the number is odd. |
IsPositive(this byte) | Indicates if the number is zero or positive. (Always true for unsigned numbers) |
IsPowerOfTwo(this byte) | Determines if the number is a power of two. |
PopCount(this byte) | Counts the bits that are set to 1 in a number. |
RotateLeft(this byte, int) | Performs a bitwise left rotation on a number. |
RotateRight(this byte, int) | Performs a bitwise right rotation on a number. |
RoundUpToPowerOfTwo(this byte) | For any given number return the number if it’s a power of two, or return the next higher power of two capable of fitting in the data type. |