Re: problem with string.format %d and very large integers
[
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: 2011年7月28日 13:51:37 -0400
On 2011年7月27日 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).