Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
__ solution in Clear category for Friendly Number by Cjkjvfnby
def friendly_number(number, base=1000, decimals=0, suffix='',
powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']):
sign = number < 0 and '-' or ''
template = '{}%.{}f%s{}'.format(sign, decimals, suffix)
number = abs(number)
for power in powers[:-1]:
if number < base:
return template % (number, power)
if decimals:
number /= base
else:
number //= base
return template % (number, powers[-1])
May 24, 2014