lua-users home
lua-l archive

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


Am 27.11.2010 21:16, schrieb Andreas Falkenhahn:
> Hi,
>
> why does this code not print "yo"?
>
> ---snip---
> local x = 1.1
> x = x + 0.1
> if x == 1.2 then
> print("yo")
> end
> ---snap---
>
> x is set to 1.2 but the if clause isn't entered. Can anybody explain why?
>
> Tks,
>
> Andreas
>
>
The answer is very simple:

> x= 1.1+0.1
> print(string.format("x = %.20f", x))
x = 1.20000000000000017764

You may find a  solution at http://lua-users.org/wiki/SimpleRound

Regads BB