Feature Flag
Version-Specific Operators
Bitwise Binary Operators
Lua 5.3 introduces several bitwise operators as part ofBinOp:
Operator Precedence
| Operator | Precedence | Description | |
|---|---|---|---|
// | 10 | Floor division (same as *, /, %) | |
<<, >> | 7 | Bitwise shifts | |
& | 6 | Bitwise AND | |
~ | 5 | Bitwise XOR | |
| ` | ` | 4 | Bitwise OR |
Examples
Bitwise NOT (Unary Operator)
Lua 5.3 adds the bitwise NOT operator:Example
Usage
Inherited Features
Sincelua53 enables lua52, you also get:
- Goto statements and labels (see Lua 5.2)
- All Lua 5.2 syntax features
Notes
- All bitwise operators work on integers
- The
~operator serves as both unary bitwise NOT and binary bitwise XOR depending on context - Floor division
//always rounds toward negative infinity, unlike truncating division/ - Lua 5.3 also supports integer literals with the
0xprefix and fractional hexadecimal numbers