lua-users home
lua-l archive

Re: Strange add results

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


2010年11月20日 Alexey Malyshev <malma@kaluga.net>:
> What's wrong with this code?
>
> local i = 1
> i = i + 0.2
> i = i + 0.2
> i = i + 0.2
> i = i + 0.2
> i = i + 0.2
> print(i)
> print(tostring( i ~= 2))
Because under the floating point specification, 0.2 cannot be
accurately represented.
- Jim

AltStyle によって変換されたページ (->オリジナル) /