[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: problem with string.format %d and very large integers
- From: "Stuart P. Bentley" <stuart@...>
- Date: Thu, 28 Jul 2011 13:51:37 -0400
On Wed, 27 Jul 2011 16:57:06 -0400, Norman Ramsey <nr@cs.tufts.edu> wrote:
There is, however, an ANSI C
solution for the common case in which the "precision" is left
implicit: Lua could implement %d by using '%.0f' internally.
I'd like to see this solved with defines in a config, with something like
#define LUA_STRFORMAT_FLOATINGINT sizeof(int) < sizeof(lua_Number)
#if LUA_STRFORMAT_FLOATINGINT
#define LUA_STRFORMAT_INTEGER = "%.0f"
#else
#define LUA_STRFORMAT_INTEGER = "%d"
#endif
I've actually been impacted by this problem before, with large negative
numbers (I solved it by changing "%d" to "-%d" and the input from v to -v).