* 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)
| 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 |