lua-users home
lua-l archive

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


On 25/03/2014 21.05, Tim Hill wrote:
That said, for this project I cannot recall needing arithmetic shift,
just logical.

Probably because logical shifts are bitwise operations acting on bit arrays of defined length, assuming no intepretation of their meaning and therefore having many different applications where they cannot easily be replaced, while arithmetic shifts are just a shortcut for arithmetic operations on integer values coded in a specific way: two different beasts.

I don't use arithmetical shifts in C because thy are not guaranteed and because their meaning is, in fact, an integer division of a signed value by an unsigned power of two. I find it safer and clearer to write the latter.

Of course there may be particolr cases where one may want to operate on signed integer values at bit level, but they are much less common than generic bit manipulation or bit level operations on unsigned values.

--
  Enrico