standardizing on binary units

Jason Schoon floydpink at gmail.com
Wed May 3 02:50:21 UTC 2006


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.

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.



More information about the busybox mailing list