Skip to content

KBE3D / KBCore / Cesium / Math / isPowerOfTwo

函数: isPowerOfTwo()

isPowerOfTwo(n: number): boolean

Determines if a non-negative integer is a power of two. The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.

参数

n

number

The integer to test in the range [0, (2^32)-1].

返回

boolean

true if the number if a power of two; otherwise, false.

示例

ts
const t = Cesium.Math.isPowerOfTwo(16); // true
const f = Cesium.Math.isPowerOfTwo(20); // false

KBE3D @3.0.0 Copyright © 2024-present KBE3D