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