# File lib/ruby-vpi/integer.rb, line 76
  def unpack aPackedWidth
    bits = length

    unless aPackedWidth >= bits
      raise ArgumentError, "packed width #{aPackedWidth} must be at least #{bits} for integer #{self}"
    end

    mask = aPackedWidth.to_mask
    result = self & mask

    if result[aPackedWidth - 1] == 1
      -((-result) & mask)
    else
      result
    end
  end