def num_to_micro_amount(num, precision=2):
  """
  Converts a number into micro-amounts (multiplied by 1M), rounded to
  specified precision. Useful for more easily working with currency,
  and also for communicating with DFP API.

  Args:
    num (float or int)
    precision (int)
  Returns:
    an integer: int(num * 1,000,000), rounded to the nearest
      10^(6-`precision`)
  """
  rounding = -6 + precision
  return int(round(num * (10 ** 6), rounding))