Click or drag to resize
DigitalRuneMathHelperBitmask Method
Creates the smallest bitmask that is greater than or equal to the given value.

Namespace: DigitalRune.Mathematics
Assembly: DigitalRune.Mathematics (in DigitalRune.Mathematics.dll) Version: 1.14.0.0 (1.14.0.14427)
Syntax
[CLSCompliantAttribute(false)]
public static uint Bitmask(
	uint value
)

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