lua-users home
lua-l archive

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

Quoth Doug Currie <>, on 2010-01-14 22:54:12 -0500:
> ...unless we were Common Lisp programmers in another life. There,
> (ash x n), or bit.ashift(x, n), as it might be spelled in Lua, is
> defined simply as an integer x * 2^n.
> They are useful for do-it-yourself floating point: arithmetic on the
> exponents lead to signed shift adjustments of the mantissas.

Note that math.ldexp is already present, at least when Lua numbers are
doubles.  Having ldexp be signed-shift-argument shift when numbers are
integers would be an interesting graceful degradation for the X * 2^N

   ---> Drake Wilson