Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

On the one hand, by (interpreter compile-time) default, all numeric values in Lua are floats, and xor on floats doesn't make a lot of sense. On the other hand, given the popularity of embedded Lua (in which case the numeric type is probably int) the lack of bitwise operators gets frustrating. Actually I can attest to this, having used Lua in an embedded context.


Actually, by default numeric values are doubles, which can easily handle a 32-bit int without losing precision. And as I posted above, the Lua bitop library (which is standard in LuaJIT and Lua 5.2) gives you bitwise operations.


I did use bitop extensively. Having every bitwise operation be a function call was not as pleasant to type (or read) as dedicated bitwise operators but it did get the job done.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: