lua-users home
lua-l archive

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


Patrick Rapin <toupie300@gmail.com> writes:
> I call them get and set. We used them quite a lot to deal with bit
> fields from hardware registers. This is how they could be defined:
>
> bit32.get(x, disp [, nbbits]) : returns the bit slice taken from
> number 'x', starting at bit # 'disp', and of size 'nbbits' bits (1 by
> default).
>
> bit32.set(val, x, disp [, nbbits]) : inserts the value 'val' as a bit
> slice into number 'x', starting at bit position 'disp', and of size
> 'nbbits' bits (1 by default). The number 'val' must be an integer
> between 0 and 2^nbbits-1.

I think the "traditional" names for these operations (e.g., instruction
names on CPUs that have such operations) are "extract" and "insert".

[And I think those names are more clear than "get" and "set"]

-Miles

-- 
Omochiroi!