function formatBigNumberToBase (n, base, size) {
  const BigNumberCtor = n.constructor
  const big2 = new BigNumberCtor(2)
  let suffix = ''
  if (size) {
    if (size < 1) {
      throw new Error('size must be in greater than 0')
    }
    if (!isInteger(size)) {
      throw new Error('size must be an integer')
    }
    if (n.greaterThan(big2.pow(size - 1).sub(1)) || n.lessThan(big2.pow(size - 1).mul(-1))) {
      throw new Error(`Value must be in range [-2^${size - 1}, 2^${size - 1}-1]`)
    }
    if (!n.isInteger()) {
      throw new Error('Value must be an integer')
    }
    if (n.lessThan(0)) {
      n = n.add(big2.pow(size))
    }
    suffix = `i${size}`
  }
  switch (base) {
    case 2: return `${n.toBinary()}${suffix}`
    case 8: return `${n.toOctal()}${suffix}`
    case 16: return `${n.toHexadecimal()}${suffix}`
    default: throw new Error(`Base ${base} not supported `)
  }
}
Formats a BigNumber in a given base
@param {BigNumber} n
@param {number} base
@param {number} size
@returns {string}