For American numbers

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Sun Feb 13 09:35:57 EST 2005


Peter Hansen wrote:
> Roel Schroeven wrote:
> 
>> Peter Hansen wrote:
>>
>>> 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.
>>
>>
>>
>> And physicists and chemists and engineers and all other kinds of 
>> scientists all over the world. Plus those of us in the computer world 
>> who agree that 'kilo == 1024' is an abomination that should never have 
>> existed and which we should get rid of as fast as possible.
> 
> 
> Physicists and chemists (and most engineers) don't go around
> talking about "kilobytes" all that often, and when they do
> it's generally unimportant whether they mean 1000 or 1024.

Scientists and engineers use kilo as a prefix for all kinds of units, 
and it means 1000 regardless of what unit it is used with. Except when 
used with bytes and some other units, and I feel that that is a 
historical misfeature.

> Given the clear "units='bytes'" default above, and my restricting
> my comments to "the rest of the computer world", it should be
> clear I was talking about a very limited subset of the planet.

"units='bytes'" means that 'bytes' is the default, but also that the 
function can be called with any other unit.

> A subset, however, which has an extremely strong attachment to
> 1024 instead of 1000 (for very good reasons),

Well, in computer science 1024 is often more practical than 1000, I'm 
not going to argue that. My point is that 1024 is not 1000 (though it is 
quite close, unfortunately), so another prefix should have been chosen 
to represent it. I don't mind interchanging 1000 and 1024 in informal 
contexts, but I think a clear distinction is needed in other cases:

- the difference between 1000 and 1024 is only 2.4%, but the difference 
between 1 GB and 1GiB is 7.4. That can IMO no longer be looked at as 
insignificant.
- computer scientists are used to having everyting just right. We're 
used to compilers that cannot deal with the slightest typo, TCP doesn't 
work right if we're ACKing the wrong sequence numbers. In the view of 
that, it feels ackward that we're so sloppy with unit prefixes.

History has tought is that standardization is a good thing, and I think 
we should start using the existing standard (SI) as it is inteded to be 
used: k as a prefix equals 1000, regardless of the context. I agree that 
'kibi', 'mebi' and 'gibi' sound silly, but I think it's better to use 
silly sounding units than units of which you can never be really sure 
what they mean.

> less likely to abandon backwards compatibility and widely accept
> 1000 than the US is likely to adopt metric widely in the near
> future...

I'm afraid you're right, but I think we should at least try.

In fact, I don't really understand that: computer science is a modern 
science, computers and other digital devices are modern stuff, but still 
the computer world is super tradionalist about this. The worst part is 
that it's a tradition we invented ourselves which is in contradiction 
with an older, commonly accepted tradition.

-- 
"Codito ergo sum"
Roel Schroeven



More information about the Python-list mailing list