UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

15 lines (12 loc) 352 B
import { assert } from "../assert.js"; /** * Is the number a power of two? * e.g. 2,4,8,16 etc. * NOTE: only valid for non-negative integers, includes 0 * @param {number} value * @returns {boolean} */ export function isPowerOfTwo(value) { assert.isNonNegativeInteger(value, 'value'); return (value & (value - 1)) === 0; }