mirror of https://github.com/AxioDL/zeus.git
Add ceilingPowerOf2
This commit is contained in:
parent
082cac124c
commit
bbb81c96b8
|
@ -92,6 +92,7 @@ namespace Math
|
|||
float fastCosR(float val);
|
||||
float fastSinR(float val);
|
||||
int floorPowerOfTwo(int x);
|
||||
int ceilingPowerOfTwo(int x);
|
||||
|
||||
template <class T>
|
||||
inline int PopCount(T x)
|
||||
|
|
16
src/Math.cpp
16
src/Math.cpp
|
@ -198,6 +198,22 @@ int floorPowerOfTwo(int x)
|
|||
return x - (x >> 1);
|
||||
}
|
||||
|
||||
int ceilingPowerOfTwo(int x)
|
||||
{
|
||||
if (x == 0)
|
||||
return 0;
|
||||
|
||||
x--;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
float fastCosR(float val)
|
||||
{
|
||||
if (fabs(val) > M_PI)
|
||||
|
|
Loading…
Reference in New Issue