lua-users home
lua-l archive

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


The output is "24".

On Tue, Sep 10, 2013 at 8:03 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2013/9/10 Michael Horvath <mikh2161@gmail.com>:
>
>> OK since this code is not working for me, does anyone have a
>> suggestion for a different PRNG implementation I could use instead?
>
> We're talking about code that runs under standard Lua 4.0.1
> but not on some non-standard Lua 4.0 that has been modified in some
> undocumented way by some unidentified game developer.
>
> I.e. the problem is not the code, it's the Lua modification. For example,
> Lua 4.0 uses a file called 'config' which contains these lines:
>
> # Lua uses double for numbers. To change this, uncomment one of the lines below.
> #NUMBER= -DLUA_NUM_TYPE=double
> #NUMBER= -DLUA_NUM_TYPE=float
> #NUMBER= -DLUA_NUM_TYPE=long
> # Optionally, you may also want change how numbers are converted to strings,
> # and vice-versa. Look for LUA_NUMBER in llimits.h and in the rest of the code.
>
> If the developer made Lua use float instead of double, of course any code
> that relies on properties like the product of two 16-bit integers being exactly
> representable is not going to work.
>
> Run this code under your Lua and tell us the output:
>
> x=1; for k=1,64 do x=2*x; if x-(x-1)~=1 then n=k-1 break end end; print(n)
>