lua-users home
lua-l archive

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


It was thus said that the Great Cosmin Apreutesei once stated:
> > If you are using double-precision Lua numbers (the default), print them
> > with %0.17g. This allows you to read them back without loss.
> 
> Thanks, that helped. Could you explain why %0.17g is a losless conversion?
> 
> To clarify, by "clean" I meant as clean as whatever the expression 5/6
> prduces. I know a float's decimals are base2 so only multiple-of-2
> decimals can be stored exactly.

  I found this (and the previous four parts, which are linked to in this
article) to be informative about floating point numbers and math:

http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

  -spc