lua-users home
lua-l archive

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

Alex wrote:
> I need to xor a couple of 64 bit long integers, specifically to seed a
> pseudo-random number generator with a combination of a couple of
> values.

You could use math.random()/math.randomseed() instead. This is a
very fast PRNG and uses all bits of the floating-point seed.

Convert the upper bits of the seed values with tonumber(x/2^12) to
FP values. Convert the lower bits with tonumber(x%2^52). Then use
FP multiplies and FP adds to mix them together.

> So I ask, is there a way to preform bitwise
> operations on 64 bit integers in native LuaJIT, and if so, how? Or if
> not, is it planned and when can I expect it?

It's on my TODO list. Not sure when I'll get around to it.