NBit Bit Manipulation Library

BitMathExtensions.RoundUpToPowerOf2 Method

Rounds a value up to the nearest power of two.

[Visual Basic]
<Extension> _
Public Shared Sub RoundUpToPowerOf2( _
   ByVal value As UInt32 _
)
[C#]
[Extension]
public static uint RoundUpToPowerOf2(
   this uint value
);

Parameters

value
The value to round up.

Return Value

The rounded-up value. Values greater than 2^31 overflow to 0.

See Also

BitMathExtensions Class | NBit Namespace