lua-users home
lua-l archive

Re: Floating point performance (was Re: compiling LUA for uClinux)

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,
Adam D. Moss wrote:
> On a similar note, poking around in luaconf.h I tried turning
> lua_number2str()'s sprintf() into a gcvt() to see if that
> gained anything. But it was actually slightly slower than
> sprintf() (which was a bit surprising because intuitively sprintf
> has to do more work, but sprintf has probably been subject to more
> optimization).
$ man gcvt | ul -Tunknown | grep -A2 NOTES
NOTES
 This function is obsolete. Instead, sprintf() is recommended.
$ tail -9 glibc-2.3.3/misc/efgcvt.c
char *
APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
 FLOAT_TYPE value;
 int ndigit;
 char *buf;
{
 sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
 return buf;
}
Bye,
 Mike

AltStyle によって変換されたページ (->オリジナル) /