Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How to format text and numbers nicely?

format Nicely Numbers text
0
10 Posted

How to format text and numbers nicely?

0
10

String concatenation works on both strings and numbers, but does not give you any control over the formatting of the numbers, which is particularly important when dealing with floating-point values. The function string.format works like C’s sprintf: you give it a string containing a format string, and a number of values. Numerical formats like ‘%5.2f’ are understood (field width of 5, two places after the decimal point) or ‘%02d’ (field width of 2, pad out with zeroes – ’01’, etc). ‘%s’ means as a string, ‘%q’ means as a quoted string, that is, a format that Lua can read back.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123