function formatNumberToBase (n, base, size) {
  const prefixes = { 2: '0b', 8: '0o', 16: '0x' }
  const prefix = prefixes[base]
  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 > 2 ** (size - 1) - 1 || n < -(2 ** (size - 1))) {
      throw new Error(`Value must be in range [-2^${size - 1}, 2^${size - 1}-1]`)
    }
    if (!isInteger(n)) {
      throw new Error('Value must be an integer')
    }
    if (n < 0) {
      n = n + 2 ** size
    }
    suffix = `i${size}`
  }
  let sign = ''
  if (n < 0) {
    n = -n
    sign = '-'
  }
  return `${sign}${prefix}${n.toString(base)}${suffix}`
}
Formats a number in a given base
@param {number} n
@param {number} base
@param {number} size
@returns {string}