standardizing on binary units

Rob Landley rob at landley.net
Tue May 2 14:32:52 PDT 2006


On Tuesday 02 May 2006 8:42 am, Robert P. J. Day 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.

It's a convenience feature which makes no difference to the size of the 
generated code, that I am aware of.

> however, while this might seem nitpicky, 

Yes.

> it's not that simple.

"It's not that simple" is generally my trigger phrase to start thinking about 
how we can avoid doing whatever it is at all.

>   the new IEC standard prefixes:
>
> http://physics.nist.gov/cuu/Units/binary.html

Anybody who believes we should adopt a name like "mebibyte" is smoking 
something, and I'm going to ignore them.  Just like I ignore IBM's insistence 
on calling a hard drive either "DASD" or "Hard File".

> now more carefully define binary multiples to distinguish them from
> simple powers of ten.  if you want to be precise, you might want to
> define macros or enum constants like:
>
>   Ki = 1024
>   Mi = 1048576

I respect the IETF because the duct tape in RFC 1149 was ruled advisory, and 
did not block a conformant implementation.  That kind of pragmatism, I can 
get behind.

Standards bodies should document, not legislate.

> and so on, so you can more precisely use values like "64 * Ki" or "4 *
> Mi" or whatever.
>
>   in any event, it *is* rather pointless to define those enum
> constants, then make so little use of them.

They're used in three or four places now, and you're welcome to use them in 
more.

Rob
-- 
Never bet against the cheap plastic solution.


More information about the busybox mailing list