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: Dimiter 'malkia' Stanev <malkia@...>
- Date: 2011年7月28日 17:13:45 -0700
Yup, but one can do it inlined
(sizeof(int)<sizeof(lua_Number)) ? "%0.f" : "%d"
or (but requires some non-header change)
const char* formatters[2] = { "%d", "%0.f" }
formatters[ sizeof(int) < sizeof( lua_Number) ]
Or this stupid trick, without requiring above:
("%d0円0円%0.f" + ((sizeof(int) < sizeof(lua_Number))<<2))
0円 is supposed to be 0 (I'm never sure how to encode this in "C")
#define LUA_STRFORMAT_FLOATINGINT sizeof(int) < sizeof(lua_Number)
#if LUA_STRFORMAT_FLOATINGINT
#define LUA_STRFORMAT_INTEGER = "%.0f"
#else
#define LUA_STRFORMAT_INTEGER = "%d"
On 7/28/2011 11:20 AM, Luiz Henrique de Figueiredo wrote:
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
That cannot work because sizeof is not evaluated at preprocessing time.