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

Method cmp

projects/JavaScript/proto/int64.js:1438–1455  ·  view source on GitHub ↗

* Compare this value to other one * @this {!UInt64} * @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

1436 * @returns {number} 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
1437 */
1438 cmp (other) {
1439 if (!Int64.isInt64(other) && !UInt64.isUInt64(other)) {
1440 other = UInt64.fromValue(other)
1441 }
1442 if (this.eq(other)) {
1443 return 0
1444 }
1445 let thisNeg = this.isNegative
1446 let otherNeg = other.isNegative
1447 if (thisNeg && !otherNeg) {
1448 return -1
1449 }
1450 if (!thisNeg && otherNeg) {
1451 return 1
1452 }
1453 // Both are positive if at least one is unsigned
1454 return (((other.high >>> 0) > (this.high >>> 0)) || ((other.high === this.high) && (other.low >>> 0) > (this.low >>> 0))) ? -1 : 1
1455 }
1456
1457 /**
1458 * Negates this value

Callers 4

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

Calls 4

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

Tested by

no test coverage detected