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

Method cmp

projects/JavaScript/proto/int64.js:524–541  ·  view source on GitHub ↗

* Compare this value to other one * @this {!Int64} * @param {!Int64|!UInt64|number|string} other Other value * @returns {number} 0 if they are the same, 1 if the this is greater and -1 if the given one is greater

(other)

Source from the content-addressed store, hash-verified

522 * @returns {number} 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
523 */
524 cmp (other) {
525 if (!Int64.isInt64(other) && !UInt64.isUInt64(other)) {
526 other = Int64.fromValue(other)
527 }
528 if (this.eq(other)) {
529 return 0
530 }
531 let thisNeg = this.isNegative
532 let otherNeg = other.isNegative
533 if (thisNeg && !otherNeg) {
534 return -1
535 }
536 if (!thisNeg && otherNeg) {
537 return 1
538 }
539 // At this point the sign bits are the same
540 return this.sub(other).isNegative ? -1 : 1
541 }
542
543 /**
544 * Negates this value

Callers 4

ltMethod · 0.95
lteMethod · 0.95
gtMethod · 0.95
gteMethod · 0.95

Calls 5

eqMethod · 0.95
subMethod · 0.95
isInt64Method · 0.80
isUInt64Method · 0.80
fromValueMethod · 0.45

Tested by

no test coverage detected