def SizeForOutput(size):
    """Return the size suitable for output in a SQL statement. Note that a
       negative size is assumed to be unlimited."""
    if size < 0:
        return 'unlimited'
    kilobytes, remainder = divmod(size, 1024)
    if not remainder:
        megabytes, remainder = divmod(kilobytes, 1024)
        if not remainder:
            return '%gm' % megabytes
        else:
            return '%gk' % kilobytes
    else:
        return '%g' % size
