diff --git a/src/include/OpenImageIO/fmath.h b/src/include/OpenImageIO/fmath.h index bb73ff14ea..ea31eb43ce 100644 --- a/src/include/OpenImageIO/fmath.h +++ b/src/include/OpenImageIO/fmath.h @@ -144,7 +144,11 @@ ispow2(T x) noexcept // Numerous references for this bit trick are on the web. The // principle is that x is a power of 2 <=> x == 1< x-1 is // all 1 bits for bits < b. - return (x & (x - 1)) == 0 && (x >= 0); + if constexpr (std::is_signed::value) { + return (x & (x - 1)) == 0 && (x >= 0); + } else { + return (x & (x - 1)) == 0; + } }