diff options
| author | Lioncash <mathew1800@gmail.com> | 2018-03-23 09:50:09 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2018-03-23 09:50:49 -0400 |
| commit | 79f40fb8d7b5a0d1efb47cd2d4a0661be9772d0e (patch) | |
| tree | 1e205b87821fecc5a1c7b4e9066bc0362f22b903 /Source/Core/Common/MathUtil.h | |
| parent | e88cc33a29c842b87211398a51b5a43af1adde2f (diff) | |
MathUtil: Generify IsPow2
This will allow it to also be used in the AArch64 emitter.
Diffstat (limited to 'Source/Core/Common/MathUtil.h')
| -rw-r--r-- | Source/Core/Common/MathUtil.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index becaf09792..58aad3522d 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -49,9 +49,10 @@ constexpr T Clamp(const T val, const T& min, const T& max) return std::max(min, std::min(max, val)); } -constexpr bool IsPow2(u32 imm) +template <typename T> +constexpr bool IsPow2(T imm) { - return (imm & (imm - 1)) == 0; + return imm > 0 && (imm & (imm - 1)) == 0; } // The most significant bit of the fraction is an is-quiet bit on all architectures we care about. |
