Skip to content
FutureBlitz

    Install

    Import std.math.bits

    NextPowerOfTwo

    std.math.bits

    function

    @PanicsAtCaller Public Function NextPowerOfTwo<T>(value: T): T

    The smallest power of two that isn't below the value: 1 for 1 and below. One too large for the type panics.

    Examples

    Expect(NextPowerOfTwo(100) == 128)
    Expect(IsPowerOfTwo(64) && !IsPowerOfTwo(65))
    Expect(AlignUp(13, 8) == 16 && AlignDown(13, 8) == 8)

    std/math/bits.fb, line 115

    Report an issue with this page or with FutureBlitz on GitHub.