lua-users home
lua-l archive

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


On 1/23/06, Rici Lake <lua@ricilake.net> wrote:
> Or fixed :) It's not the only problem with %:
>
>  > for i = 50, 70 do io.write(2^i % 3, " ") end; io.write"\n"
> 1 2 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>  > for i = 50, 70 do io.write(math.fmod(2^i, 3), " ") end; io.write"\n"
> 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
>
Seems that  this is the 14/15 digit problem with doubles. How does
fmod do it? At 2^54 we are beyond double capacity to show all digits.
So how does it know what the remainder is? Some form of
optimized arithmetic?

DB