Unexpected calculation result with Lua53

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected calculation result with Lua53

Luiz Henrique de Figueiredo
> > n=1 for i = 1,80 do n = n * i end print(n) n1=n
> 7.1569457046264e+118
> > n=1 for i = 80,1,-1 do n = n * i end print(n) n2=n
> 7.1569457046264e+118
> > return n2-n1
> 1.7917957937422e+103
>
> Only a few googols of difference....

If you print n2/n1 you'll get 1, at least to the 14 decimals shown by default.

In Lua 5.3 you need to do "n=1.0" before each loop.

12