MCPcopy Create free account
hub / github.com/esengine/esengine / getHighestBitIndex

Method getHighestBitIndex

packages/core/src/ECS/Utils/Bits.ts:316–336  ·  view source on GitHub ↗

* 获取最高位设置位的索引 * @returns 最高位设置位的索引,如果位集合为空则返回-1

()

Source from the content-addressed store, hash-verified

314 * @returns 最高位设置位的索引,如果位集合为空则返回-1
315 */
316 public getHighestBitIndex(): number {
317 if (BitMask64Utils.isZero(this._value)) {
318 return -1;
319 }
320
321 if (this._value.base[SegmentPart.HIGH] !== 0) {
322 for (let i = 31; i >= 0; i--) {
323 if ((this._value.base[SegmentPart.HIGH] & (1 << i)) !== 0) {
324 return i + 32;
325 }
326 }
327 }
328
329 for (let i = 31; i >= 0; i--) {
330 if ((this._value.base[SegmentPart.LOW] & (1 << i)) !== 0) {
331 return i;
332 }
333 }
334
335 return -1;
336 }
337
338 /**
339 * 获取最低位设置位的索引

Callers 1

Bits.test.tsFile · 0.45

Calls 1

isZeroMethod · 0.45

Tested by

no test coverage detected