Namespaces | Macros | Functions
Math.hh File Reference
#include "likely.hh"
#include <cassert>
#include <cmath>
#include <cstdint>
Include dependency graph for Math.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.




#define M_E   2.7182818284590452354
#define M_LN2   0.69314718055994530942
#define M_LN10   2.30258509299404568402
#define M_PI   3.14159265358979323846


template<typename T >
constexpr T Math::log2p1 (T x) noexcept
 Returns the number of bits needed to store the value 'x', that is: for x==0 : 0 for x!=0 : 1 + floor(log2(x)) This will be part of c++20: More...
template<typename T >
constexpr bool Math::ispow2 (T x) noexcept
 Is the given number an integral power of two? That is, does it have exactly one 1-bit in binary representation. More...
template<typename T >
constexpr T Math::floodRight (T x) noexcept
 Returns the smallest number of the form 2^n-1 that is greater or equal to the given number. More...
template<typename T >
constexpr T Math::ceil2 (T x) noexcept
 Returns the smallest number that is both >=a and a power of two. More...
template<int LO, int HI>
int Math::clip (int x)
 Clips x to the range [LO,HI]. More...
int16_t Math::clipIntToShort (int x)
 Clip x to range [-32768,32767]. More...
uint8_t Math::clipIntToByte (int x)
 Clip x to range [0,255]. More...
unsigned Math::gcd (unsigned a, unsigned b)
 Calculate greatest common divider of two strictly positive integers. More...
unsigned Math::reverseNBits (unsigned x, unsigned bits)
 Reverse the lower N bits of a given value. More...
uint8_t Math::reverseByte (uint8_t a)
 Reverse the bits in a byte. More...
unsigned Math::countLeadingZeros (unsigned x)
 Count the number of leading zero-bits in the given word. More...
unsigned Math::findFirstSet (unsigned x)
 Find the least significant bit that is set. More...
float Math::cubicHermite (const float *y, float x)

Macro Definition Documentation

◆ M_E

#define M_E   2.7182818284590452354

Definition at line 19 of file Math.hh.

◆ M_LN10

#define M_LN10   2.30258509299404568402

Definition at line 25 of file Math.hh.

◆ M_LN2

#define M_LN2   0.69314718055994530942

Definition at line 22 of file Math.hh.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 28 of file Math.hh.