Class UInt16Extensions
Numeric-related extension methods for
Inheritance
Namespace: X10D.Numerics
Assembly: X10D.dll
Syntax
public static class UInt16Extensions : object
Methods
| Improve this Doc View SourcePopCount(UInt16)
Returns the population count (number of bits set) of a mask.
Declaration
public static int PopCount(this ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The mask. |
Returns
Type | Description |
---|---|
System.Int32 | The population count of |
Remarks
This method is similar in behavior to the x86 instruction POPCNT
RotateLeft(UInt16, Int32)
Rotates the current value left by the specified number of bits.
Declaration
public static ushort RotateLeft(this ushort value, int count)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The value to rotate. |
System.Int32 | count | The number of bits by which to rotate. Any value outside the range [0..15] is treated as congruent mod 16. |
Returns
Type | Description |
---|---|
System.UInt16 | The rotated value. |
RotateRight(UInt16, Int32)
Rotates the current value right by the specified number of bits.
Declaration
public static ushort RotateRight(this ushort value, int count)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The value to rotate. |
System.Int32 | count | The number of bits by which to rotate. Any value outside the range [0..15] is treated as congruent mod 16. |
Returns
Type | Description |
---|---|
System.UInt16 | The rotated value. |
RoundUpToPowerOf2(UInt16)
Rounds the current value up to a power of two.
Declaration
public static ushort RoundUpToPowerOf2(this ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The value to round. |
Returns
Type | Description |
---|---|
System.UInt16 | The smallest power of two that's greater than or equal to |