lua-users home
lua-l archive

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


> > Addendum: Frankly it's easier to synthesize a logical shift out of an
> > arithmetic shift than the other way around. It's an easier operation
> > to mask out the high bits after an arithmetic shift than it is to test
> > the high bits, shift, and then set afterward. The former requires a
> > single extra operation; the latter requires either a conditional or a
> > multiplication by a boolean followed by the same extra operation.
> 
> This is a good argument.

Correcting some details: I guess "the former requires a single extra
operation" only applies for constant offsets, or am I missing something?
(For an unknown offset, I could not find a way to synthesize a logical
shift with less than three extra operations.)  But, for constant
offsets, an integer division synthesizes an arithmetic shift with no
extra operation.

I still would like to hear about the usefulness of both shifts.

-- Roberto