BitOperations 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.
Provides utility methods for intrinsic bittwiddling operations. The methods use hardware intrinsics when available on the underlying platform; otherwise, they use optimized software fallbacks.
public ref class BitOperations abstract sealed
public static class BitOperations
type BitOperations = class
Public Class BitOperations
 Inheritance

BitOperations
Methods
Crc32C(UInt32, Byte) 
Accumulates the CRC (Cyclic redundancy check) checksum. 
Crc32C(UInt32, UInt16) 
Accumulates the CRC (Cyclic redundancy check) checksum. 
Crc32C(UInt32, UInt32) 
Accumulates the CRC (Cyclic redundancy check) checksum. 
Crc32C(UInt32, UInt64) 
Accumulates the CRC (Cyclic redundancy check) checksum. 
IsPow2(Int32) 
Evaluates whether the specified Int32 value is a power of two. 
IsPow2(Int64) 
Evaluates whether the specified Int64 value is a power of two. 
IsPow2(IntPtr) 
Determines whether the specified integral value is a power of 2. 
IsPow2(UInt32) 
Evaluates whether the specified UInt32 value is a power of two. 
IsPow2(UInt64) 
Evaluates whether the specified UInt64 value is a power of two. 
IsPow2(UIntPtr) 
Determines whether the specified integral value is a power of 2. 
LeadingZeroCount(UInt32) 
Counts the number of leading zero bits in an unsigned 32bit integer mask. 
LeadingZeroCount(UInt64) 
Counts the number of leading zero bits in an unsigned 64bit integer mask. 
LeadingZeroCount(UIntPtr) 
Counts the number of leading zero bits in a mask. Similar in behavior to the x86 instruction LZCNT. 
Log2(UInt32) 
Returns the integer (floor) log of the specified value, base 2. 
Log2(UInt64) 
Returns the integer (floor) log of the specified value, base 2. 
Log2(UIntPtr) 
Returns the integer (floor) log of the specified value, base 2. 
PopCount(UInt32) 
Returns the population count (number of bits set) of a mask. 
PopCount(UInt64) 
Returns the population count (number of bits set) of an unsigned 64bit integer mask. 
PopCount(UIntPtr) 
Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT. 
RotateLeft(UInt32, Int32) 
Rotates the specified value left by the specified number of bits. 
RotateLeft(UInt64, Int32) 
Rotates the specified value left by the specified number of bits. 
RotateLeft(UIntPtr, Int32) 
Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL. 
RotateRight(UInt32, Int32) 
Rotates the specified value right by the specified number of bits. 
RotateRight(UInt64, Int32) 
Rotates the specified value right by the specified number of bits. 
RotateRight(UIntPtr, Int32) 
Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR. 
RoundUpToPowerOf2(UInt32) 
Rounds the specified UInt32 value up to a power of two. 
RoundUpToPowerOf2(UInt64) 
Rounds the specified UInt64 value up to a power of two. 
RoundUpToPowerOf2(UIntPtr) 
Rounds the given integral value up to a power of 2. 
TrailingZeroCount(Int32) 
Counts the number of trailing zero bits in an 32bit integer value mask. 
TrailingZeroCount(Int64) 
Counts the number of trailing zero bits in a 64bit integer value mask. 
TrailingZeroCount(IntPtr) 
Counts the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT. 
TrailingZeroCount(UInt32) 
Counts the number of trailing zero bits in an unsigned 32bit integer value mask. 
TrailingZeroCount(UInt64) 
Count the number of trailing zero bits in an unsigned 64bit integer value mask. 
TrailingZeroCount(UIntPtr) 
Counts the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT. 
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for