lua-users home
lua-l archive

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


2014-03-23 16:58 GMT+02:00 Thijs Schreijer <thijs@thijsschreijer.nl>:

> I find it confusing that the operator '~' is used for both 'xor' and 'unary not'.

Think of it this way. Prefix `-` is related to infix `-` by the identity

   -x == 0-x

Prefix `~`, as your examples so clearly demonstrate, is related to infix `~` by

   ~x == (-1)~x

since -1 == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF