BitHelper Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Helpers to perform bit operations on numeric types.
public static class BitHelper
type BitHelper = class
Public Class BitHelper
- Inheritance
-
BitHelper
Methods
ExtractRange(UInt32, Byte, Byte) |
Extracts a bit field range from a given value. |
ExtractRange(UInt64, Byte, Byte) |
Extracts a bit field range from a given value. |
HasByteEqualTo(UInt32, Byte) |
Checks whether a byte in the input UInt32 value matches a target value. |
HasByteEqualTo(UInt64, Byte) |
Checks whether a byte in the input UInt32 value matches a target value. This method mirrors HasByteEqualTo(UInt32, Byte), but with UInt64 values. |
HasFlag(UInt32, Int32) |
Checks whether or not a given bit is set. |
HasFlag(UInt64, Int32) |
Checks whether or not a given bit is set. |
HasLookupFlag(UInt32, Int32, Int32) |
Checks whether or not a given bit is set in a given bitwise lookup table.
This method provides a branchless, register-based (with no memory accesses) way to
check whether a given value is valid, according to a precomputed lookup table.
It is similar in behavior to HasFlag(UInt32, Int32), with the main difference
being that this method will also validate the input
The resulted assembly is virtually identical, with the added optimization that the one produced by HasLookupFlag(UInt32, Int32, Int32) has no conditional branches at all. |
HasLookupFlag(UInt64, Int32, Int32) |
Checks whether or not a given bit is set in a given bitwise lookup table. For more info, check the XML docs of the HasLookupFlag(UInt32, Int32, Int32) overload. |
HasZeroByte(UInt32) |
Checks whether the given value has any bytes that are set to 0. That is, given a UInt32 value, which has a total of 4 bytes, it checks whether any of those have all the bits set to 0. |
HasZeroByte(UInt64) |
Checks whether the given value has any bytes that are set to 0. This method mirrors HasZeroByte(UInt32), but with UInt64 values. |
SetFlag(UInt32, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt32, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt64, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt64, Int32, Boolean) |
Sets a bit to a specified value. |
SetRange(UInt32, Byte, Byte, UInt32) |
Sets a bit field range within a target value. |
SetRange(UInt32, Byte, Byte, UInt32) |
Sets a bit field range within a target value. |
SetRange(UInt64, Byte, Byte, UInt64) |
Sets a bit field range within a target value. |
SetRange(UInt64, Byte, Byte, UInt64) |
Sets a bit field range within a target value. |