[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 9 Sep 2013 10:02:52 -0300
> > 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
- References:
- why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, pulleyzzz_gmail
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Leo Razoumov
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland