gdk-graphics 0a0aef92e917cfbac53dffbc32c295e4de914093
Loading...
Searching...
No Matches
constraints.h
1// © Joseph Cameron - MIT License
2
3#ifndef GDK_GRAPHICS_CONSTRAINTS_H
4#define GDK_GRAPHICS_CONSTRAINTS_H
5
6#include <cstddef>
7
8namespace gdk::graphics {
9 constexpr bool is_power_of_two(const std::size_t aNumber) {
10 return aNumber != 0 && (aNumber & (aNumber - 1)) == 0;
11 }
12
14 constexpr std::size_t square_root(const std::size_t aNumber) {
15 std::size_t root = 0;
16
17 while ((root + 1) * (root + 1) <= aNumber) ++root;
18
19 return root;
20 }
21}
22
23#endif
24