int vs float divide: abbreviating numbers w/SI units
Erik Max Francis
max at alcyone.com
Sat Jul 28 15:34:02 EDT 2001
David Eppstein wrote:
> SI Units are used to convert the number to a human-readable
> For example, abbreviateNumber(3141592) returns '3.1M'.
> In most cases (except when the number is too big or too small
> for the units defined in the SI system) the resulting string
> will be at most four characters long.
Those are SI prefixes, not units. (Under strict SI rules, you're not
supposed to use the prefixes without units; 3M to represent 3 x 10^6 is
badly formed SI usage.)
> By default, the program uses decimal k (i.e. 1k = 1000).
> To use binary k, as is more typical e.g. for numbers of bytes,
> call with a second argument k=1024.
There is a standard for binary prefixes, too: Ki, Mi, Gi, Ti, etc.; not
that they're used much.
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Dear World: I am leaving because I am bored.
\__/ George Sanders (in his suicide note)
REALpolitik / http://www.realpolitik.com/
Get your own customized newsfeed online in realtime ... for free!
More information about the Python-list