Photon Fusion 2.1.3

BitOperations Class Reference

Fallback implementations for Unity builds that cannot use the .NET versions. More...

Static Public Member Functions

static bool IsPow2 (UInt32 value)
 Evaluate whether a given integral value is a power of 2.
static bool IsPow2 (UInt64 value)
 Evaluate whether a given integral value is a power of 2.
static bool IsPow2 (UIntPtr value)
 Evaluate whether a given integral value is a power of 2.
static Int32 LeadingZeroCount (UInt32 value)
 Count the number of leading zero bits in a mask. Similar in behavior to the x86 instruction LZCNT.
static Int32 LeadingZeroCount (UInt64 value)
 Count the number of leading zero bits in a mask. Similar in behavior to the x86 instruction LZCNT.
static Int32 Log2 (UInt32 value)
 Returns the integer (floor) log of the specified value, base 2. Note that by convention, input value 0 returns 0 since log(0) is undefined.
static Int32 Log2 (UInt64 value)
 Returns the integer (floor) log of the specified value, base 2. Note that by convention, input value 0 returns 0 since log(0) is undefined.
static Int32 Log2 (UIntPtr value)
 Returns the integer (floor) log of the specified value, base 2. Note that by convention, input value 0 returns 0 since log(0) is undefined.
static Int32 PopCount (UInt32 value)
 Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT.
static Int32 PopCount (UInt64 value)
 Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT.
static Int32 PopCount (UIntPtr value)
 Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT.
static UInt32 RotateLeft (UInt32 value, Int32 offset)
 Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL.
static UInt64 RotateLeft (UInt64 value, Int32 offset)
 Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL.
static UIntPtr RotateLeft (UIntPtr value, Int32 offset)
 Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL.
static UInt32 RotateRight (UInt32 value, Int32 offset)
 Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR.
static UInt64 RotateRight (UInt64 value, Int32 offset)
 Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR.
static UIntPtr RotateRight (UIntPtr value, Int32 offset)
 Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR.
static UInt32 RoundUpToPowerOf2 (UInt32 value)
 Round the given integral value up to a power of 2.
static UInt64 RoundUpToPowerOf2 (UInt64 value)
 Round the given integral value up to a power of 2.
static UIntPtr RoundUpToPowerOf2 (UIntPtr value)
 Round the given integral value up to a power of 2.
static Int32 TrailingZeroCount (Int32 value)
 Count the number of trailing zero bits in an integer value. Similar in behavior to the x86 instruction TZCNT.
static Int32 TrailingZeroCount (Int64 value)
 Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.
static Int32 TrailingZeroCount (IntPtr value)
 Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.
static Int32 TrailingZeroCount (UInt32 value)
 Count the number of trailing zero bits in an integer value. Similar in behavior to the x86 instruction TZCNT.
static Int32 TrailingZeroCount (UInt64 value)
 Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.
static Int32 TrailingZeroCount (UIntPtr value)
 Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.

Detailed Description

Fallback implementations for Unity builds that cannot use the .NET versions.

Member Function Documentation

◆ IsPow2() [1/3]

bool IsPow2 ( UInt32 value)
static

Evaluate whether a given integral value is a power of 2.

Parameters
valueThe value.

◆ IsPow2() [2/3]

bool IsPow2 ( UInt64 value)
static

Evaluate whether a given integral value is a power of 2.

Parameters
valueThe value.

◆ IsPow2() [3/3]

bool IsPow2 ( UIntPtr value)
static

Evaluate whether a given integral value is a power of 2.

Parameters
valueThe value.

◆ LeadingZeroCount() [1/2]

Int32 LeadingZeroCount ( UInt32 value)
static

Count the number of leading zero bits in a mask. Similar in behavior to the x86 instruction LZCNT.

Parameters
valueThe value.

◆ LeadingZeroCount() [2/2]

Int32 LeadingZeroCount ( UInt64 value)
static

Count the number of leading zero bits in a mask. Similar in behavior to the x86 instruction LZCNT.

Parameters
valueThe value.

◆ Log2() [1/3]

Int32 Log2 ( UInt32 value)
static

Returns the integer (floor) log of the specified value, base 2. Note that by convention, input value 0 returns 0 since log(0) is undefined.

Parameters
valueThe value.

◆ Log2() [2/3]

Int32 Log2 ( UInt64 value)
static

Returns the integer (floor) log of the specified value, base 2. Note that by convention, input value 0 returns 0 since log(0) is undefined.

Parameters
valueThe value.

◆ Log2() [3/3]

Int32 Log2 ( UIntPtr value)
static

Returns the integer (floor) log of the specified value, base 2. Note that by convention, input value 0 returns 0 since log(0) is undefined.

Parameters
valueThe value.

◆ PopCount() [1/3]

Int32 PopCount ( UInt32 value)
static

Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT.

Parameters
valueThe value.

◆ PopCount() [2/3]

Int32 PopCount ( UInt64 value)
static

Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT.

Parameters
valueThe value.

◆ PopCount() [3/3]

Int32 PopCount ( UIntPtr value)
static

Returns the population count (number of bits set) of a mask. Similar in behavior to the x86 instruction POPCNT.

Parameters
valueThe value.

◆ RotateLeft() [1/3]

UInt32 RotateLeft ( UInt32 value,
Int32 offset )
static

Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL.

Parameters
valueThe value to rotate.
offsetThe number of bits to rotate by. Any value outside the range [0..31] is treated as congruent mod 32.
Returns
The rotated value.

◆ RotateLeft() [2/3]

UInt64 RotateLeft ( UInt64 value,
Int32 offset )
static

Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL.

Parameters
valueThe value to rotate.
offsetThe number of bits to rotate by. Any value outside the range [0..63] is treated as congruent mod 64.
Returns
The rotated value.

◆ RotateLeft() [3/3]

UIntPtr RotateLeft ( UIntPtr value,
Int32 offset )
static

Rotates the specified value left by the specified number of bits. Similar in behavior to the x86 instruction ROL.

Parameters
valueThe value to rotate.
offsetThe number of bits to rotate by. Any value outside the range [0..31] is treated as congruent mod 32 on a 32-bit process, and any value outside the range [0..63] is treated as congruent mod 64 on a 64-bit process.
Returns
The rotated value.

◆ RotateRight() [1/3]

UInt32 RotateRight ( UInt32 value,
Int32 offset )
static

Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR.

Parameters
valueThe value to rotate.
offsetThe number of bits to rotate by. Any value outside the range [0..31] is treated as congruent mod 32.
Returns
The rotated value.

◆ RotateRight() [2/3]

UInt64 RotateRight ( UInt64 value,
Int32 offset )
static

Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR.

Parameters
valueThe value to rotate.
offsetThe number of bits to rotate by. Any value outside the range [0..63] is treated as congruent mod 64.
Returns
The rotated value.

◆ RotateRight() [3/3]

UIntPtr RotateRight ( UIntPtr value,
Int32 offset )
static

Rotates the specified value right by the specified number of bits. Similar in behavior to the x86 instruction ROR.

Parameters
valueThe value to rotate.
offsetThe number of bits to rotate by. Any value outside the range [0..31] is treated as congruent mod 32 on a 32-bit process, and any value outside the range [0..63] is treated as congruent mod 64 on a 64-bit process.
Returns
The rotated value.

◆ RoundUpToPowerOf2() [1/3]

UInt32 RoundUpToPowerOf2 ( UInt32 value)
static

Round the given integral value up to a power of 2.

Parameters
valueThe value.
Returns
The smallest power of 2 which is greater than or equal to value . If value is 0 or the result overflows, returns 0.

◆ RoundUpToPowerOf2() [2/3]

UInt64 RoundUpToPowerOf2 ( UInt64 value)
static

Round the given integral value up to a power of 2.

Parameters
valueThe value.
Returns
The smallest power of 2 which is greater than or equal to value . If value is 0 or the result overflows, returns 0.

◆ RoundUpToPowerOf2() [3/3]

UIntPtr RoundUpToPowerOf2 ( UIntPtr value)
static

Round the given integral value up to a power of 2.

Parameters
valueThe value.
Returns
The smallest power of 2 which is greater than or equal to value . If value is 0 or the result overflows, returns 0.

◆ TrailingZeroCount() [1/6]

Int32 TrailingZeroCount ( Int32 value)
static

Count the number of trailing zero bits in an integer value. Similar in behavior to the x86 instruction TZCNT.

Parameters
valueThe value.

◆ TrailingZeroCount() [2/6]

Int32 TrailingZeroCount ( Int64 value)
static

Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.

Parameters
valueThe value.

◆ TrailingZeroCount() [3/6]

Int32 TrailingZeroCount ( IntPtr value)
static

Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.

Parameters
valueThe value.

◆ TrailingZeroCount() [4/6]

Int32 TrailingZeroCount ( UInt32 value)
static

Count the number of trailing zero bits in an integer value. Similar in behavior to the x86 instruction TZCNT.

Parameters
valueThe value.

◆ TrailingZeroCount() [5/6]

Int32 TrailingZeroCount ( UInt64 value)
static

Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.

Parameters
valueThe value.

◆ TrailingZeroCount() [6/6]

Int32 TrailingZeroCount ( UIntPtr value)
static

Count the number of trailing zero bits in a mask. Similar in behavior to the x86 instruction TZCNT.

Parameters
valueThe value.