import math


def human_filesize(filesize):
    """Display the filesize in a human-readable unit."""
    if filesize > 0:
        names = [" ", "k", "M", "G", "T", "P", "E"]
        exponent = math.floor(math.log(filesize, 1000))
        digits = filesize / math.pow(1000, exponent)
        prefix = names[exponent]

        return "%6.2f %sB" % (digits, prefix)
    else:
        return "  0.00  B"