lua-users home
lua-l archive

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


On 3/5/2014 3:29 AM, Dio Darkclainer wrote:
I found new strangeness:

math.floor(math.log(2^n, 2)^a)) --> n^a - 1

Yeah, this is not a surprising thing to some of us.

Tell us what your OS and compiler combination is.

Some older math libraries for certain compiler and OS combinations are known to produce such results. Try a short C program and you'll get the same result. Good math libraries will special-case situations where exact results are expected.

2014-03-04 15:43 GMT+04:00 Dio Darkclainer :

    Hello all!
    Code:

    for i=1,20 do
        if math.floor(math.log(2^i,2)) ~= i then
           print(i)
        end
    end

    will be output
    3
    6
    12
    13

    if use math.log(2^i)/math.log(2) intstead all work correctly
    lua 5.2.3


--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia