lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Mar 9, 2009 at 3:18 PM, Ico <lua@zevv.nl> wrote:
> In the embedded field hexadecimal notation is very common, especially in
> things like protocols or hardware registers where every bit can have a
> separate meaning. Converting mentally between bits and hex is quite
> trivial once you get the hang of it, but converting between bits and
> decimal is much harder to do.

I'd very much like this, too.

Most protocol and data dumpers dump data as hex. It's the standard way
of expressing binary data.

Some old tools use octal, it's even the default for C character codes,
I think as a hold-over from the early 7 bit architectures unix was
developed on? Anyhow, its also fairly easy to convert octal to and
from bits.

Decimal notation doesn't have anything to recommend it, as far as I
can tell. Anybody who is inserting bytes using numerical values would
want to be using hex.

> (Speaking of bits: I also like to make my vote heard for the addition of
> bit-handling functions, or even better, operators to the lua core. I'd
> kill for some high-performance bit clear, set, shift, and, or, and
> similar operations!)

http://bitop.luajit.org/

Cheers,
Sam