Dusk Audio Framework
Loading...
Searching...
No Matches
Math related functions

Functions

template<typename T>
static constexpr bool d_isEqual (const T &v1, const T &v2)
template<typename T>
static constexpr bool d_isNotEqual (const T &v1, const T &v2)
template<typename T>
static constexpr bool d_isZero (const T &value)
template<typename T>
static constexpr bool d_isNotZero (const T &value)
static bool d_isFinite (const double value) noexcept
static bool d_isFinite (const float value) noexcept
static uint32_t d_nextPowerOf2 (uint32_t size) noexcept
template<typename T>
static constexpr int32_t d_roundToIntPositive (const T &value)
template<typename T>
static constexpr uint32_t d_roundToUnsignedInt (const T &value)
template<typename T>
static constexpr int32_t d_roundToIntNegative (const T &value)
template<typename T>
static constexpr int32_t d_roundToInt (const T &value)

Detailed Description

Function Documentation

◆ d_isEqual()

template<typename T>
constexpr bool d_isEqual ( const T & v1,
const T & v2 )
inlinestaticconstexpr

Safely compare two floating point numbers. Returns true if they match.

◆ d_isNotEqual()

template<typename T>
constexpr bool d_isNotEqual ( const T & v1,
const T & v2 )
inlinestaticconstexpr

Safely compare two floating point numbers. Returns true if they don't match.

◆ d_isZero()

template<typename T>
constexpr bool d_isZero ( const T & value)
inlinestaticconstexpr

Safely check if a floating point number is zero.

◆ d_isNotZero()

template<typename T>
constexpr bool d_isNotZero ( const T & value)
inlinestaticconstexpr

Safely check if a floating point number is not zero.

◆ d_isFinite() [1/2]

bool d_isFinite ( const double value)
inlinestaticnoexcept

Check if a floating point number is finite, that is neither infinite nor NaN.

Use this instead of std::isfinite, std::isnan or std::isinf on values from outside your own code, such as parameter values from the host. DAF's Makefile builds compile with -ffast-math, which lets the compiler assume that no value is ever infinite or NaN, and GCC and Clang then fold those checks to a constant: the check is silently compiled out. This reads the bit pattern instead, through a volatile, so neither compiler can apply that assumption to it.

◆ d_isFinite() [2/2]

bool d_isFinite ( const float value)
inlinestaticnoexcept

Check if a floating point number is finite, that is neither infinite nor NaN.

See also
d_isFinite(double)

◆ d_nextPowerOf2()

uint32_t d_nextPowerOf2 ( uint32_t size)
inlinestaticnoexcept

Get next power of 2.

◆ d_roundToIntPositive()

template<typename T>
constexpr int32_t d_roundToIntPositive ( const T & value)
inlinestaticconstexpr

Round a floating point number to an integer. Fast operation for values known to be 0 or positive.

◆ d_roundToUnsignedInt()

template<typename T>
constexpr uint32_t d_roundToUnsignedInt ( const T & value)
inlinestaticconstexpr

Round a floating point number to an unsigned integer. Fast operation for values known to be 0 or positive.

◆ d_roundToIntNegative()

template<typename T>
constexpr int32_t d_roundToIntNegative ( const T & value)
inlinestaticconstexpr

Round a floating point number to an integer. Fast operation for values known to be 0 or negative.

◆ d_roundToInt()

template<typename T>
constexpr int32_t d_roundToInt ( const T & value)
inlinestaticconstexpr

Round a floating point number to integer.