"docs/vscode:/vscode.git/clone" did not exist on "9a3f49ae07f9627db02b2ee377accb76b65d1d1e"
math.hpp 339 Bytes
Newer Older
1
2
#pragma once

3
4
5
#include <climits>
#include <iostream>

6
inline constexpr uint32_t next_pow_2(uint32_t const num) {
7
8
  if (num <= 1) return num;
  return 1 << (CHAR_BIT * sizeof(num) - __builtin_clz(num - 1));
9
10
11
12
13
}

template <typename T>
inline constexpr std::enable_if_t<std::is_integral_v<T>, T> ceil_div(T a, T b) {
  return (a + b - 1) / b;
14
}