def human_format(num, precision=0):
    """
    Format a number as a string, suffixing letter for 1000 (K), 100000 (M), ...

    :param num: any number larger than zero
    :param precision: number of positions after decimal point
    :return: string representing the number
    """
    magnitude = 0
    while abs(num) >= 1000:
        magnitude += 1
        num /= 1000.0
    return '{:.{prec}f}{}'.format(num, ['', 'k', 'M', 'G', 'T', 'P'][
        magnitude], prec=precision)
