| MathHelperBitmask Method |
Creates the smallest bitmask that is greater than or equal to the given value.
Namespace: DigitalRune.MathematicsAssembly: DigitalRune.Mathematics (in DigitalRune.Mathematics.dll) Version: 1.14.0.0 (1.14.0.14427)
Syntax [CLSCompliantAttribute(false)]
public static uint Bitmask(
uint value
)
<CLSCompliantAttribute(false)>
Public Shared Function Bitmask (
value As UInteger
) As UInteger
public:
[CLSCompliantAttribute(false)]
static unsigned int Bitmask(
unsigned int value
)
[<CLSCompliantAttribute(false)>]
static member Bitmask :
value : uint32 -> uint32
Parameters
- value
- Type: SystemUInt32
The value.
Return Value
Type:
UInt32
A bitmask where the left bits are 0 and the right bits are 1. The value of the bitmask
is ≥
value.
Remarks
This result can also be interpreted as finding the smallest x such that 2x >
value and returning 2x - 1.
Another useful application: Bitmask(x) + 1 returns the next power of 2 that is greater than
x.
See Also