diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-08-10 17:53:07 +0100 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-08-10 17:53:07 +0100 |
| commit | 4cbcb3ace7c0d066e8d5105e4b3582300f93d533 (patch) | |
| tree | d72f8a02240728364cd86e5a8148b26e3c79f40a /src/common.cpp | |
| parent | da76c743e9b7c88f2f15bbee1dba3b2ab6ebc0b0 (diff) | |
Add shortcut for `unsigned_x/power_of_two` -> `unsigned_x >> log2(power_of_two)`
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index 53848cacf..5b007bf2c 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -80,6 +80,13 @@ gb_internal gb_inline bool is_power_of_two(i64 x) { return !(x & (x-1)); } +gb_internal gb_inline bool is_power_of_two_u64(u64 x) { + if (x == 0) { + return false; + } + return !(x & (x-1)); +} + gb_internal int isize_cmp(isize x, isize y) { if (x < y) { return -1; |