lua-users home
lua-l archive

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


> > =math.fmod(235.7, 0.05)
> 0.049999999999976

This is not a bug in Lua. It's a limitation of floating point arithmetic.
Neither 235.7 nor 0.05 have exact representation in floating point:

  > print(string.format("%.20f",235.7))
  235.69999999999998863132
  > print(string.format("%.20f",0.05))
  0.05000000000000000278

See for instance http://floating-point-gui.de .