0.1+0.2 definitely not 0.3 . Try this code:
print((0.1+0.2)==0.3) print(string.format("%.17g",0.1+0.2))
I assume that you are using print or io.write to print these values. In this case, Lua just does not print all the numbers. Internally, Lua uses a full-size, native floating-point representation. The technical explanation is that the print and io.write format io.write are used in the LUA_NUMBER_FMT format defined in luaconf.h , which defaults to "%.14g" .
source share