[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: 5.1 rc mod giving -0 (never just 0)**
**From**: D Burgess <dburgess@...>
**Date**: Mon, 23 Jan 2006 16:22:23 +1100

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