openMSX
Namespaces | Macros | Functions
Math.hh File Reference
#include "likely.hh"
#include <algorithm>
#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.

Namespaces

 Math
 

Macros

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

Functions

constexpr bool Math::isPowerOfTwo (unsigned a)
 Is the given number an integer power of 2? Not correct for zero (according to this test 0 is a power of 2). More...
 
unsigned Math::powerOfTwo (unsigned a)
 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...
 
template<typename T >
Math::floodRight (T x)
 Returns the smallest number of the form 2^n-1 that is greater or equal to the given number. 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...
 

Macro Definition Documentation

◆ M_E

#define M_E   2.7182818284590452354

Definition at line 18 of file Math.hh.

Referenced by cstd::exp(), and cstd::log().

◆ M_LN10

#define M_LN10   2.30258509299404568402

Definition at line 24 of file Math.hh.

◆ M_LN2

#define M_LN2   0.69314718055994530942

Definition at line 21 of file Math.hh.

Referenced by cstd::exp2().

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 27 of file Math.hh.

Referenced by gl::degrees(), gl::radians(), and TEST_CASE().