def format_file_size(v):
  """Format file size into a human friendly format"""
  if abs(v) > 10**12:
    return '%.2f TB' % (v / 10**12)
  elif abs(v) > 10**9:
    return '%.2f GB' % (v / 10**9)
  elif abs(v) > 10**6:
    return '%.2f MB' % (v / 10**6)
  elif abs(v) > 10**3:
    return '%.2f kB' % (v / 10**3)
  else:
    return '%d B' % v