Math::CeilDiv (divide and round up)

This commit is contained in:
Alpyne 2020-10-30 18:55:20 -07:00
parent 1c55884ddc
commit 55fa33057f
1 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#pragma once
#include "../Common.h"
#include <cstdint>
namespace Feather::Math
@ -44,4 +45,12 @@ namespace Feather::Math
{
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);
}
}