standardizing on binary units

walter harms wharms at bfs.de
Sun May 7 16:33:37 UTC 2006



Jason Schoon wrote:
> On 5/2/06, Robert P. J. Day <rpjday at mindspring.com> wrote:
>>
>>   another aesthetic nitpick but, if include/libbb.h is going to define
>> the enumeration constants:
>>
>> enum {
>>     KILOBYTE = 1024,
>>     MEGABYTE = (KILOBYTE*1024),
>>     GIGABYTE = (MEGABYTE*1024)
>> };
>>
>> it only makes sense that busybox code should start using those
>> constants, rather than constantly reproduce numeric constants like
>> "1024", "65536" and so on.  however, while this might seem nitpicky,
>> it's not that simple.
> 
> Generally, I am all for getting rid of "magic" numbers and replacing
> them with defines.  It helps determine why that value was chosen, and
> also makes changing the value later happen in one place rather than
> many.
> 
> However, a Kilobyte is not going to change, regardless of whether
> these new crazy standards ever take off.  If I see 1024 in the code,
> or KILOBYTE, my brain reads 1024 in either case.


you know the old joke that programmers think that kilometer is 1024 meters ?


> I don't think there is a space savings in either case, so I guess it
> really doesn't matter to me how they are used.  I won't go out of my
> way to use the define in this case though.

Whole whole stuff does not realy matter if you work with 'small' 
numbers, with larger numbers the error starts to matter. thats the 
reason the 'kibi' and friends were added.
The standard simply tries to end the 'confusion' between 1000 and 1024.

short: i support the change simply its no big step NOW, what ever 
happens later in time.

re,
  wh




More information about the busybox mailing list