lua-users home
lua-l archive

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

On 18/01/2010 15:40, Roberto Ierusalimschy wrote:
I agree with you on this. Arithmetic right shift is a primitive
operation and I couldn't live without it.

Just a remind: at least we would be in good company, as ANSI C does not
offer this operation too :)

   ISO/IEC 9899:1999 (E)
   The result of E1>>  E2 is E1 right-shifted E2 bit positions.  If E1
   has an unsigned type or if E1 has a signed type and a nonnegative
   value, the value of the result is the integral part of the quotient of
   E1 / 2E2.  If E1 has a signed type and a negative value, the resulting
   value is implementation-defined.

In the risk of shocking some people, C isn't the ultimate reference. Is it? :)
In Java (thus JavaScript) and perhaps some other languages, we have the >>> operator... for unsigned right shift.

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --