lua-users home
lua-l archive

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


2013/9/11 Michael Horvath <mikh2161@gmail.com>:

> function mul16(a, b)
> local a_lo, b_lo = mod(a, 2^8), mod(b, 2^8)
> local a_hi, b_hi = a - a_lo, b - b_lo
> return mod(a_lo * b_lo + mod(a_lo * b_hi, 2^16) + mod(a_hi * b_lo,
> 2^16) + mod(a_hi * b_hi, 2^16), 2^16)
> end

Yes, that's simplest. Any generator that works with 16-bit integers
(and that used to be standard) will work with this.