human_format()¶
- audplot.human_format(number)[source]¶
Display large or small numbers in a human readable way.
It replaces large or small numbers by no more than 3 significant digits and no more than 1 fractional digit. Instead it adds a string indicating the base, e.g. 12345 becomes 12.3k.
The naming is according to:
n
\(10^{-9}\)
nano
u
\(10^{-6}\)
micro
m
\(10^{-3}\)
milli
k
\(10^{3}\)
thousand
M
\(10^{6}\)
Million
Mega
B
\(10^{9}\)
Billion
Giga
T
\(10^{12}\)
Trillion
Tera
P
\(10^{15}\)
Quadrillion
Peta
E
\(10^{18}\)
Quintillion
Exa
Z
\(10^{21}\)
Sextillion
Zetta
Y
\(10^{24}\)
Septillion
Yotta
- Parameters
- Return type
- Returns
formatted number string
- Raises
ValueError – if
number
\(\ge 1000^9\) ornumber
\(\le 1000^{-4}\)
Examples
>>> human_format(12345) '12.3k' >>> human_format(1234567) '1.2M' >>> human_format(123456789000) '123B' >>> human_format(0.000123) '123u' >>> human_format(0) '0' >>> human_format(-1000) '-1k'