lua-users home
lua-l archive

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


>If you look at the source for most
>*printf implementations, you'll see that only a tiny fraction of it is
>concerned with converting numbers to strings.

Not so. Most systems derived from BSD include David Gay's dtoa, which is huge
(but does exactly what we want, which is being able to real numbers convert
from and to strings without losing precision, so that the *exact* number can be
reproduced; this is very difficult to get right in all cases).

Another reason for including our own very tiny printf is that it uses Lua
strings and hence does not suffer from buffer-size limitations in sprintf,
which had forced us to write lots of %.99s format specifiers and use many local
buffers of arbitrary length. The code is much cleaner now, and probably smaller
as a whole. Moreover, we were able to export this to the API as a service.
--lhf