diff --git a/Int64.js b/Int64.js index 608ae23..d394c4a 100644 --- a/Int64.js +++ b/Int64.js @@ -228,6 +228,21 @@ Int64.prototype = { this.buffer.copy(targetBuffer, targetOffset || 0, this.offset, this.offset + 8); }, + /** + * Returns a number indicating whether this comes before or after or is the + * same as the other in sort order. + * + * @param {Int64} other Other Int64 to compare. + */ + compare: function(other) { + for (var i = 0; i < 8; i++) { + if (this.buffer[this.offset+i] !== other.buffer[other.offset+i]) { + return this.buffer[this.offset+i] - other.buffer[other.offset+i]; + } + } + return 0; + }, + /** * Pretty output in console.log */