为啥抛出这个错误?
luajit -e 'local bit = require "bit" print(bit.lshift(0xffffffffffLL, 1))'
luajit: (command line):1: bad argument #1 to 'lshift' (number expected, got cdata)
stack traceback:
[C]: in function 'lshift'
(command line):1: in main chunk
[C]: at 0x0100002150
在 2016年6月22日星期三 UTC+8下午1:32:48,agentzh写道:
Hello!
On Wed, Jun 8, 2016 at 3:14 AM, codingforfan wrote:
> 看到luajit2.1已经支持64bit位运算了,然后升级了下luajit,貌似并不管用呢,求解?
>
> http://luajit.org/sponsors.html#sponsorship_bit64
>
> 或者有其他方法来支持64bit的位运算么?
>
可以。通过 int64_t 或者 uint64_t 类型的 FFI cdata 类型。比如:
$ luajit -e 'local bit = require "bit" print(bit.lshift(0xffffffffffLL, 1))'
2199023255550LL
Regards,
-agentzh