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

Method NumBits

projects/JavaScript/proto/int64.js:389–404  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

387 * @returns {number} Number of represented bits
388 */
389 get NumBits () {
390 if (this.isNegative) {
391 return this.eq(INT64_MIN) ? 64 : this.neg().NumBits
392 }
393
394 let val = (this.high !== 0) ? this.high : this.low
395
396 let bit
397 for (bit = 31; bit > 0; bit--) {
398 if ((val & (1 << bit)) !== 0) {
399 break
400 }
401 }
402
403 return (this.high !== 0) ? (bit + 33) : (bit + 1)
404 }
405
406 /**
407 * Is this value zero?

Callers

nothing calls this directly

Calls 2

eqMethod · 0.95
negMethod · 0.95

Tested by

no test coverage detected