[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bitop multiplication overflow semantics
- From: Daurnimator <quae@...>
- Date: Tue, 22 Jan 2013 00:01:09 +1100
Use the ffi:
> ffi = require "ffi"
> to_uint32 = ffi.ctype("uint32_t")
> x=12345678
> =to_uint32(x*0xcc9e2d51)
cdata<unsigned int>: 0x40e2eb28
On 21 January 2013 23:34, Cosmin Apreutesei <cosmin.apreutesei@gmail.com> wrote:
> Hi,
>
> I wanted to port a hash function from C to LuaJIT. First thing the
> algorithm does is it takes the first uint32_t of the key and
> multiplies it with 0xcc9e2d51, the destination variable being itself a
> uint32_t. I don't know the semantics of this in C, but whatever it is,
> can I emulate this in LuaJIT / LuaBitOp or other library? This
> multiplication would exceed 53bit if it were between Lua numbers.
>
> Thanks.
>