lua-users home
lua-l archive

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

> The problem, according to the IEEE floating point entries on Wikipedia, is that there are not enough digits specified.

This is on purpose so that numbers appear right for the casual user:

     > a=0.1
     > =a
     > =string.format("%.17g",a)

We don't want needless noise when using print (and other automatic
conversions via tostring). If you need round-trip strings, then use

This also happens in Python for instance (but I think we did not get
that idea from them):

     >>> a=0.1
     >>> a
     >>> str(a)
     >>> "{:.17g}".format(0.1)