MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / NumBits

Method NumBits

projects/JavaScript/proto/int64.js:1303–1318  ·  view source on GitHub ↗

* Gets the number of bits needed to represent the absolute value of this UInt64 * @this {!UInt64} * @returns {number} Number of represented bits

()

Source from the content-addressed store, hash-verified

1301 * @returns {number} Number of represented bits
1302 */
1303 get NumBits () {
1304 if (this.isNegative) {
1305 return this.eq(UINT64_MIN) ? 64 : this.neg().NumBits
1306 }
1307
1308 let val = (this.high !== 0) ? this.high : this.low
1309
1310 let bit
1311 for (bit = 31; bit > 0; bit--) {
1312 if ((val & (1 << bit)) !== 0) {
1313 break
1314 }
1315 }
1316
1317 return (this.high !== 0) ? (bit + 33) : (bit + 1)
1318 }
1319
1320 /**
1321 * Is this value zero?

Callers

nothing calls this directly

Calls 2

eqMethod · 0.95
negMethod · 0.95

Tested by

no test coverage detected