Math::CeilDiv (divide and round up)
This commit is contained in:
parent
1c55884ddc
commit
55fa33057f
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Feather::Math
|
namespace Feather::Math
|
||||||
|
@ -44,4 +45,12 @@ namespace Feather::Math
|
||||||
{
|
{
|
||||||
return CeilLog2(x) - (IsPowerOf2(x) ? 0 : 1);
|
return CeilLog2(x) - (IsPowerOf2(x) ? 0 : 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Divide and round up
|
||||||
|
template<typename T>
|
||||||
|
inline constexpr T CeilDiv(const T a, const T b)
|
||||||
|
{
|
||||||
|
return (a / b) + (a % b != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue