robosats/api/nick_generator/utils.py

9 lines
261 B
Python
Raw Normal View History

2022-10-25 18:04:12 +00:00
from math import floor, log
def human_format(number):
units = ["", " Thousand", " Million", " Billion", " Trillion", " Quatrillion"]
k = 1000.0
magnitude = int(floor(log(number, k)))
return "%.2f%s" % (number / k**magnitude, units[magnitude])