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

Method add

projects/JavaScript/proto/int64.js:561–594  ·  view source on GitHub ↗

* Add this value to other one * @this {!Int64} * @param {!Int64|!UInt64|number|string} other Other value * @returns {!Int64} Sum of the values

(other)

Source from the content-addressed store, hash-verified

559 * @returns {!Int64} Sum of the values
560 */
561 add (other) {
562 if (!Int64.isInt64(other) && !UInt64.isUInt64(other)) {
563 other = Int64.fromValue(other)
564 }
565
566 // Divide each number into 4 chunks of 16 bits, and then sum the chunks
567
568 let a48 = this.high >>> 16
569 let a32 = this.high & 0xFFFF
570 let a16 = this.low >>> 16
571 let a00 = this.low & 0xFFFF
572
573 let b48 = other.high >>> 16
574 let b32 = other.high & 0xFFFF
575 let b16 = other.low >>> 16
576 let b00 = other.low & 0xFFFF
577
578 let c48 = 0
579 let c32 = 0
580 let c16 = 0
581 let c00 = 0
582 c00 += a00 + b00
583 c16 += c00 >>> 16
584 c00 &= 0xFFFF
585 c16 += a16 + b16
586 c32 += c16 >>> 16
587 c16 &= 0xFFFF
588 c32 += a32 + b32
589 c48 += c32 >>> 16
590 c32 &= 0xFFFF
591 c48 += a48 + b48
592 c48 &= 0xFFFF
593 return Int64.fromBits((c16 << 16) | c00, (c48 << 16) | c32)
594 }
595
596 /**
597 * Subtract other value from this value

Callers 15

subMethod · 0.95
copyMethod · 0.45
fromStringMethod · 0.45
negMethod · 0.45
divMethod · 0.45
fromStringMethod · 0.45
negMethod · 0.45
divMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45

Calls 4

isInt64Method · 0.80
isUInt64Method · 0.80
fromValueMethod · 0.45
fromBitsMethod · 0.45

Tested by 15

sendAndReceiveMethod · 0.36
sendAndReceiveFinalMethod · 0.36
serializationDomainMethod · 0.36
cloneStructsMethod · 0.36
serializationDomainMethod · 0.36
extendingOldNewMethod · 0.36