The disjunction operator or returns its first argument if this value is different from nil and false; otherwise, or returns its second argument. [/quote] Since the first argument (1) evaluates to true, it is returned, so the expression "1 or 2" evaluates to 1. or is not bitwise or, but logical or. A quick search suggests that there are no bitwise operators in standard Lua, but there are libraries for it.
A quick search suggests that there are no bitwise operators in standard Lua, but there are libraries for it.
Quite true for current Lua version yet the next version has bitops as does LuaJIT. There is a module which implements the same operators for 5.1 as 5.2 , 5.2 however uses a different syntax to LuaJIT but there is a module for 5.1 which is compatible with LuaJIT syntax.
Yes this has always annoyed me about Lua not having native bit-wise ops. It seems especially odd to me considering that Lua is a tiny language designed with embedded platforms in mind, which you think would be making more use of bit-wise operations than standard high-level application code would.