lua-users home
lua-l archive

string.format("%f", ...) receiving string argument

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


Hi lua-l@,
I have this:
x = tostring(math.huge)
print(string.format("%f", x))
Reference manuals for both 5.1 and 5.2 say that option f expects a number.
However, 5.1 prints 'inf' and 5.2 breaks with:
stdin:1: bad argument #2 to 'format' (number expected, got string)
stack traceback:
 [C]: in function 'format'
 stdin:1: in main chunk
 [C]: in ?
If I use something like x="foo", both break.
Is this expected?
Thank you.

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