[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: arithmetics bug?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 31 Mar 2013 19:46:11 +0200
2013/3/31 Mason Mackaman <masondeanm@aol.com>:
> Can you set the decimal precision in Lua?
Not the internal precision, but you can set the
default printing format as follows:
function set_number_format(fmt)
debug.setmetatable(0,{
__tostring = function(x)
return fmt:format(x) end})
end
> print(1/3)
0.33333333333333
> set_number_format"%.5f"
> print(1/3)
0.33333