unstd.math

Additions to $(STDMODULE _math).

Public Imports

std.math
public import std.math;

Members

Functions

alignDown
size_t alignDown(size_t alignment, size_t n)
size_t alignDown(size_t n)
alignUp
size_t alignUp(size_t alignment, size_t n)
size_t alignUp(size_t n)

Aligns n up or down.

isAligned
bool isAligned(size_t alignment, size_t n)
bool isAligned(size_t n)

Aligns n up or down.

isPowerOf2
bool isPowerOf2(size_t n)

Returns true iff n is a power of 2.

log2RoundedDown
ubyte log2RoundedDown(size_t n)

Returns the base-2 logarithm of largest power of 2 which <= n.

log2RoundedUp
ubyte log2RoundedUp(size_t n)

Returns the base-2 logarithm of smallest power of 2 which >= n.

roundDownToPowerOf2
size_t roundDownToPowerOf2(size_t n)

Returns largest power of 2 which <= n.

roundUpToPowerOf2
size_t roundUpToPowerOf2(size_t n)

Returns smallest power of 2 which >= n.

Meta

Authors

Denis Shelomovskij