Skip to content

Commit 108514a

Browse files
committed
More math
1 parent df32186 commit 108514a

File tree

4 files changed

+1835
-567
lines changed

4 files changed

+1835
-567
lines changed

modules/yup_core/maths/yup_MathsFunctions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,15 @@ constexpr unsigned int truncatePositiveToUnsignedInt (FloatType value) noexcept
701701
template <typename IntegerType>
702702
constexpr bool isPowerOfTwo (IntegerType value)
703703
{
704-
return (value & (value - 1)) == 0;
704+
return value != 0 && (value & (value - 1)) == 0;
705705
}
706706

707707
/** Returns the smallest power-of-two which is equal to or greater than the given integer. */
708708
constexpr int nextPowerOfTwo (int n) noexcept
709709
{
710+
if (n <= 0)
711+
return 1;
712+
710713
--n;
711714
n |= (n >> 1);
712715
n |= (n >> 2);

0 commit comments

Comments
 (0)