[luatex] behavior of string.format

Harald Hanche-Olsen harald.hanche-olsen at ntnu.no
Sun Mar 10 16:01:57 CET 2019

From: Akira Kakuto <kakuto at w32tex.org>
Date: 10 March 2019 at 15:27:09

> bad argument #2 to 'format' (number has no integer representation) 

I think that this is a difference between lua-5.2 and lua-5.3. 
lua-5.3 seems to require, for example: 
string.format('%d', math.floor(math.pi)) 
Or string.format('%.0f',math.pi).

That will follow different rounding rules, though, so that if you feed it math.exp(1), you get '3', not '2'.

Even the format string '%.f' gives the same result in practice, but only '%.0f' guarantees the absence of a decimal point according to the specification (see man sprintf).

– Harald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20190310/d2f10e34/attachment.html>

More information about the luatex mailing list