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

Method toBinaryString

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

* 将位集合转换为二进制字符串 * @param maxBits 最大位数,默认为64 * @returns 二进制字符串表示,每8位用空格分隔

(maxBits: number = 0)

Source from the content-addressed store, hash-verified

237 * @returns 二进制字符串表示,每8位用空格分隔
238 */
239 public toBinaryString(maxBits: number = 0): string {
240 if(maxBits == 0){
241 maxBits = 64 + (this._value.segments ? this._value.segments.length * 64 : 0);
242 }
243 let result = '';
244 for (let i = maxBits - 1; i >= 0; i--) {
245 result += this.get(i) ? '1' : '0';
246 if (i % 8 === 0 && i > 0) {
247 result += ' ';
248 }
249 }
250 return result;
251 }
252
253 /**
254 * 将位集合转换为十六进制字符串

Callers 1

Bits.test.tsFile · 0.45

Calls 1

getMethod · 0.95

Tested by

no test coverage detected