For American numbers
Peter Hansen
peter at engcorp.com
Sat Feb 12 22:29:46 EST 2005
Scott David Daniels wrote:
> Kind of fun exercise (no good for British English).
>
> def units(value, units='bytes'):
> magnitude = abs(value)
> if magnitude >= 1000:
> for prefix in ['kilo mega giga tera peta '
> 'exa zetta yotta').split():
> magnitude /= 1000.
> if magnitude < 1000.:
> break
Only for hard drive manufacturers, perhaps.
For the rest of the computer world, unless I've missed
a changing of the guard or something, "kilo" is 1024
and "mega" is 1024*1024 and so forth...
-Peter
More information about the Python-list
mailing list