lua-users home
lua-l archive

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

2014-03-04 14:46 GMT+02:00 Dio Darkclainer <>:
>>> if use math.log(2^i)/math.log(2) instead all work correctly
>> Does it continue working correctly if you increase the upper
>> bound of the loo[?
> Work correctly with all number up to upper bound (if you mean 2^1023)


The same applies to

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

I.e. the correctly rounded values of math.log(2^i)  and i*math.log(2)
are always equal. That requires some explanation, not the fact that
math.log(2^i,2) does not always evaluate to exacly i.