def METHOD_NAME(
    value: float | Decimal, unit: str, factor: int, prefixes: t.Iterable[str]
) -> str:
    units = list(chain(unit, (p + unit for p in prefixes)))
    if value > 0:
        n = min(int(log(value, factor).real), len(units)-1)
        #todo change decimal formatting appropriately, previous {0:,4f} is wrong
        return f"{float(value)/factor**n:,f} {units[n]}"
    return f"0 {units[0]}"