mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-28 06:13:01 +00:00
util-math: Fix compile error and add get_power_of_two_*
This commit is contained in:
parent
391fca7497
commit
528d36a13f
1 changed files with 14 additions and 2 deletions
|
@ -84,7 +84,7 @@ namespace util {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool is_power_of_two(T v)
|
inline bool is_power_of_two(T v)
|
||||||
{
|
{
|
||||||
return T(1ull << uint64_t(log10(T(size)) / log10(2.0))) == v;
|
return T(1ull << uint64_t(floor(log10(T(v)) / log10(2.0)))) == v;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -118,5 +118,17 @@ namespace util {
|
||||||
is_power_of_two_as_loop(int64_t);
|
is_power_of_two_as_loop(int64_t);
|
||||||
is_power_of_two_as_loop(uint64_t);
|
is_power_of_two_as_loop(uint64_t);
|
||||||
#pragma pop_macro("is_power_of_two_as_loop")
|
#pragma pop_macro("is_power_of_two_as_loop")
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline uint64_t get_power_of_two_floor(T v)
|
||||||
|
{
|
||||||
|
return uint64_t(floor(log10(T(v)) / log10(2.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline uint64_t get_power_of_two_ceil(T v)
|
||||||
|
{
|
||||||
|
return uint64_t(ceil(log10(T(v)) / log10(2.0)));
|
||||||
|
}
|
||||||
} // namespace math
|
} // namespace math
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|
Loading…
Reference in a new issue