lua-users home
lua-l archive

Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?

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


> > Do we really want "tostring(0.1)" to return "0.10000000000000001"?
> 
> Yes, I think we do. If you wanted something to LOOK pretty, instead of
> having it be CORRECT, you wouldn't use tostring() -- you'd be using
> print.format().
Well, we do not. We could debate whether tostring{} -> 0x83ffda8 or even
tostring("123") is CORRECT. Anyway, the manual is very clear about it:
 "Receives an argument of any type and converts it to a string in a
 reasonable format."
The key word there is *reasonable*.
-- Roberto

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