Add utils.is_pot(n) to check for power-of-two.

This commit is contained in:
Colby Klein 2015-04-01 01:29:45 -07:00
parent cb4ba40bad
commit a5eaebd622

View File

@ -23,4 +23,10 @@ function utils.wrap(v, n)
return v % n
end
-- from undef: https://love2d.org/forums/viewtopic.php?p=182219#p182219
-- check if a number is a power-of-two
function utils.is_pot(n)
return 0.5 == (math.frexp(n))
end
return utils