* 将位集合转换为二进制字符串 * @param maxBits 最大位数,默认为64 * @returns 二进制字符串表示,每8位用空格分隔
(maxBits: number = 0)
| 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 | * 将位集合转换为十六进制字符串 |