Skip to content

KBE3D / KBCore / Cesium / Math / previousPowerOfTwo

函数: previousPowerOfTwo()

previousPowerOfTwo(n: number): number

Computes the previous power-of-two integer less than or equal to the provided non-negative integer. 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].

返回

number

The previous power-of-two integer.

示例

ts
const n = Cesium.Math.previousPowerOfTwo(29); // 16
const m = Cesium.Math.previousPowerOfTwo(32); // 32

KBE3D @3.0.0 Copyright © 2024-present KBE3D