lib/types/integer.js
function Integer (bits, sign) {
  /**
   * @type {!Array.<number>}
   * @private
   */
  this.bits_ = [];

  /**
   * @type {number}
   * @private
   */
  this.sign_ = sign;

  // Copy the 32-bit signed integer values passed in.  We prune out those at the
  // top that equal the sign since they are redundant.
  var top = true;
  for (var i = bits.length - 1; i >= 0; i--) {
    var val = bits[i] | 0;
    if (!top || val != sign) {
      this.bits_[i] = val;
      top = false;
    }
  }
}
function Integer (bits, sign) {
  /**
   * @type {!Array.<number>}
   * @private
   */
  this.bits_ = [];

  /**
   * @type {number}
   * @private
   */
  this.sign_ = sign;

  // Copy the 32-bit signed integer values passed in.  We prune out those at the
  // top that equal the sign since they are redundant.
  var top = true;
  for (var i = bits.length - 1; i >= 0; i--) {
    var val = bits[i] | 0;
    if (!top || val != sign) {
      this.bits_[i] = val;
      top = false;
    }
  }
}
Constructs a two's-complement integer an array containing bits of the
integer in 32-bit (signed) pieces, given in little-endian order (i.e.,
lowest-order bits in the first piece), and the sign of -1 or 0.

See the from* functions below for other convenient ways of constructing
Integers.

The internal representation of an integer is an array of 32-bit signed
pieces, along with a sign (0 or -1) that indicates the contents of all the
other 32-bit pieces out to infinity.  We use 32-bit pieces because these are
the size of integers on which Javascript performs bit-operations.  For
operations like addition and multiplication, we split each number into 16-bit
pieces, which can easily be multiplied within Javascript's floating-point
representation without overflow or change in sign.

@constructor
@param {Array.<number>} bits Array containing the bits of the number.
@param {number} sign The sign of the number: -1 for negative and 0 positive.
@final